osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

python 3.5 raiaing an error when import the class Manager in this module sayning name Manager is not define


On Wednesday, 12 July 2017 18:01:35 UTC+5:30, WoFy The 95s  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)

i removed some space and it worked thanks a lot