Skip to content

Instantly share code, notes, and snippets.

@jabooticaba
Created May 5, 2021 17:39
Show Gist options
  • Save jabooticaba/1eab64d848d3593daafd234f5046a171 to your computer and use it in GitHub Desktop.
Save jabooticaba/1eab64d848d3593daafd234f5046a171 to your computer and use it in GitHub Desktop.
генератор
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