Code below, not sure what i’m doing wrong. It is an employee database. The below inherits from from the Employee class. Not really sure what to do to get it to pass, unless my code is just wrong. I get this error ” SyntaxError: non-keyword arg after keyword arg”
class Manager(EmpSalaried): #inherits from EmpSalaried
def __init__(self, salary=0.0, firstName="", lastName="", ssID="", DOB=datetime.fromordinal(1),
startDate=datetime.today(),
manage=[]): #manage attribute added for manager
Employee.__init__(self, salary, firstName, lastName, ssID, DOB, startDate)
self.manage = manage
def __str__(self):
"""
>>> import datetime
>>> e = Manager(10, 'Bob', 'Quux', '123', startDate=datetime.datetime(2009, 1, 1),
['Michael', 'Bob', 'Hello'])
>>> print e
10, Bob Quux, 123, 0001-01-01 00:00:00, 2009-01-01 00:00:00, Michael, Bob, Hello
>>> b = Manager(2000, 'Bob', 'Lol', '1234', startDate=datetime.datetime(2009, 1, 1),
['Michael', 'Bob', 'Hello'])
>>> print b
2000, Bob Lol, 1234, 0001-01-01 00:00:00, 2009-01-01 00:00:00
"""
return Employee.__str__(self) + ', ' + str(self.manage) #need to convert to a string in order to add to string
Doctests are formatted in just the same way as you would run an interactive session. You can run an interactive session and just copy it and you’ll get all the results. This might be one valid session:
There were assorted syntax errors in what you had done;
...(exactly the same as in a regular session);Managerinstantiation was invalid (genuine PythonSyntaxError) as you hadstartDate=...(a keyword argument) followed by a non-keyword argument (the value for “manager”). This is the main problem that stopped it from running. And that’s also what the exception told you.If you can’t figure it out in a doctest, run it in a normal Python session. Play with it there.
There are also a number of other significant problems in your code; here are a couple of them:
EmpSalariedversusEmployee: what gives with that?manageargument when creating aManager, they will get the same list. This is not what you want.