If I have the following code:
class Foo(object): bar = 1 def bah(self): print(bar) f = Foo() f.bah()
It complains
NameError: global name ‘bar’ is not defined
How can I access class/static variable bar within method bah?
Instead of
baruseself.barorFoo.bar. Assigning toFoo.barwill create a static variable, and assigning toself.barwill create an instance variable.