Код: Выделить всё
class A:
def __init__(self, p):
self.p = p
def flash(self, i = self.p):
return i*i
a = A(2)
print(a)
Код: Выделить всё
Traceback (most recent call last):
File "/home/xan/tmp/z.py", line 1, in
class A:
......
return i*i
File "/home/xan/tmp/z.py", line 6, in A
def flash(self, i = self.p):
^^^^
NameError: name 'self' is not defined
Подробнее здесь: https://stackoverflow.com/questions/793 ... in-methods
Мобильная версия