On Tue, 18 Oct 2022 at 01:39, Abderrahim Adrabi <abderrahim.adr...@gmail.com> wrote: > So, these default values behave like class attributes, here is a demo: > > # Using a list ----------------------------- > class GameOne: > def __init__(self, games = []) -> None: > self.games = games >
This makes the default be a single list, the same list for all of them. If you want the default to be "construct a new list", you'll need something else: def __init__(self, games=None): if games is None: games = [] There is an open proposal to allow this syntax, which would do what you want: def __init__(self, games=>[]): However, this is not part of any current version of Python. ChrisA -- https://mail.python.org/mailman/listinfo/python-list