1

Is there the concept of collections of Models in Python 3.

For example, if I have something like

class Game(object):
    id = ''
    status = Status()
    home = Team()
    away = Team()

How can I then have a collection of "Game"s ?

Something that I could then append another "Game" to, etc.

eat-sleep-code
  • 4,753
  • 13
  • 52
  • 98

2 Answers2

1

Yes, you can use list for instance, e.g. [Game()], and use list.append to append another game. You can also annotate the name holding such collection as list[Game] for it to be checked by a static type checker like mypy.

McSinyx
  • 164
  • 2
  • 8
0

Are you wanting to get all the items from the class "Game"?

Take a look at this answer: https://stackoverflow.com/a/1251702/12036707

Code Disease
  • 64
  • 1
  • 3
  • 10