Created
May 5, 2021 17:39
-
-
Save jabooticaba/1eab64d848d3593daafd234f5046a171 to your computer and use it in GitHub Desktop.
генератор
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def id_generator(): | |
for i in range(1, 10001): | |
yield i | |
gen = id_generator() | |
class Employee: | |
def __init__(self, name, id =''): | |
self.name = name | |
self.id = id | |
class Volunteer(Employee): | |
def __init__(self, name, city, status): | |
self.city = city | |
self.status = status | |
Employee.__init__(self, name, "E" + str(next(gen))) | |
def display(self): | |
return f'{self.name}, г.{self.city}, статус "{self.status}"' | |
vol = Volunteer("Иван Петров", "Москва", "Наставник") | |
print(vol.display()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment