In my constructor, the name and description parameters are supposed to default to None if they are not entered. I think I have that part set up correctly. If name isn't entered and defaults to None, a ValueError is thrown:
My question is, how does my constructor know which parameters are left out? I know Python is dynamically typed, so if I left out the name, wouldn't it think that methodCount is actually name? How would I pass this?
Would it automatically, from the statement above, set name and description to None?
def __init__(self, name = None, methodCount, locCount, description = None): if(name == None): raise ValueError("Stats.__init__: invalid parm") else: self.theName = name if(description != None): self.theDescription = description self.theMethodCount = methodCount self.theLocCount = locCount
My question is, how does my constructor know which parameters are left out? I know Python is dynamically typed, so if I left out the name, wouldn't it think that methodCount is actually name? How would I pass this?
myStats = stats.Stats(3,15)
Would it automatically, from the statement above, set name and description to None?