Код: Выделить всё
class A:
def __init__(self, files=[]) -> None:
print(len(files))
files.append('hello')
class B:
def __init__(self) -> None:
self.file_one = A()
def f(self):
# ! files default to ['hello'], why?
self.file_two =A()
B().f()
Код: Выделить всё
0
1
Подробнее здесь: https://stackoverflow.com/questions/792 ... d-behavior
Мобильная версия