Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PersonBase:
- employment = "Unemployed"
- def __init__(self, name, employment=None):
- self.name = name
- if employment is not None:
- self.employment = employment
- def greeting(self):
- print("My name {}, and I am a {}".format(
- self.get_name(),
- self.get_employment()
- ))
- def get_name(self):
- return self.name
- def get_employment(self):
- return self.employment
- person_1 = PersonBase("John", "Doctor")
- # person_1 = type.__call__(PersonBase, "John", "Doctor")
- person_2 = PersonBase("Mathew", "Teacher")
- # person_2 = type.__call__(PersonBase, "Mathew", "Teacher")
- person_3 = PersonBase("Mathew")
- # person_3 = type.__call__(PersonBase, "Mathew")
- person_1.greeting()
- person_2.greeting()
- person_3.greeting()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement