fork download
  1.  
  2. class Goom(object):
  3. items = []
  4.  
  5. def __init__(self, name, seats, jump):
  6. """Инициализация"""
  7. self.name = name
  8. self.seats = seats
  9. self.jump = jump
  10. Goom.items.append(self)
  11.  
  12. def __str__(self):
  13. return "{} {} {}".format(self.name, self.seats, self.jump)
  14.  
  15. @classmethod
  16. def __getitem__(cls, index):
  17. return cls.item[index]
  18.  
  19.  
  20. my_goom1 = Goom("Лил", "1", "Нет")
  21. my_goom2 = Goom("Мак", "1", "Есть")
  22. my_goom3 = Goom("Ной", "1", "Есть")
  23.  
  24. print(Goom[0])
  25.  
Runtime error #stdin #stdout #stderr 0.15s 23428KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 24, in <module>
TypeError: 'type' object is not subscriptable