I'm feeling more dumb than usual, sorry. Can someone put me out of my misery and explain why __init__
can't see class variable s
?
Thanks.
class C:
s = "but why"
def __init__(self):
print(s)
c = C()
#global DEFAULT_STRING = "(undefined)"
Error
Traceback (most recent call last):
File "/Users/pvdl/Desktop/FH.sp18python/hw/7/test5.py", line 7, in module
c = C()
File "/Users/pvdl/Desktop/FH.sp18python/hw/7/test5.py", line 5, in __init__
print(s)
NameError: name 's' is not defined
Process finished with exit code 1