Here's an example Project class:
class Fruit(object):
def __init__(self, id, linesOfCode, methods):
self.theID = id
self.LOC = linesOfCode
self.theMethods = methods
Here's the Repository class:
class Repository(object):
def __init__(self):
self.theRepository = []
def addProject(project): #THIS IS MY PROBLEM!
self.theRepository.append(project)
Now, to add a project with this format I would need to do two lines of code (after creating a repository):
rep = Repository() myProject = Project(1, 45, 3) rep.addProject(myProject)
However, I'd like to do this:
rep = Repository() rep.addProject(project = Project(1, 45, 3))
Every time I do this, it keeps telling me that Project is an "undefined variable." I'm thinking this is a simple fix in the formatting of the parameter that addProject accepts, but for some reason, I can't get it to work!
Any help would be greatly appreciated.

New Topic/Question
Reply



MultiQuote



|