python 3.5 raiaing an error when import the class Manager in this module sayning name Manager is not define
WoFy The 95s
lunkambamuk at gmail.com
Wed Jul 12 09:10:14 EDT 2017
On Wednesday, 12 July 2017 18:20:32 UTC+5:30, Steve D'Aprano wrote:
> Please COPY AND PASTE the FULL error, starting with the line "Traceback".
>
> The code you show below looks fine, and you don't need an import, so I don't
> know what error you are getting.
>
>
> On Wed, 12 Jul 2017 10:31 pm, lunkambamuk at gmail.com wrote:
>
> > class Person:
> > def __init__(self, name, job=None, pay=0):
> > self.name = name
> > self.job = job
> > self.pay = pay
> > def lastName(self):
> > return self.name.split()[-1]
> > def giveRaise(self, percent):
> > self.pay = int(self.pay * (1 + percent))
> > def __repr__(self):
> > return '[Person: %s, %s]' % (self.name, self.pay)
> > class Manager(Person):
> > def giveraise(self, percent, bonus=.10):
> > Person.giveRaise(self, percent + bonus)
> >
> > if __name__ == '__main__':
> > #self-test code
> > bob = Person('Bob Smith')
> > sue = Person('Sue Jones', job='dev', pay=100000)
> > print(bob)
> > print(sue)
> > print(bob.lastName(), sue.lastName())
> > sue.giveRaise(.10)
> > print(sue.pay)
> > tom = Manager('Tom Jones', 'mgr', 50000)
> > tom.giveRaise(.10)
> > print(tom.lastName())
> > print(tom)
>
> --
> Steve
> “Cheer up,” they said, “things could be worse.” So I cheered up, and sure
> enough, things got worse.
only in python 3.5.3
More information about the Python-list
mailing list