Python Class Attribute Referencing
This is a sample code that i found from one of the python class tutorial. class MyClass: i = 12345 def f(self): return 'hello world' print MyClass.f print MyClass.
Solution 1:
Create an instance of MyClass first.
test = MyClass()
print test.f()
print MyClass.i
You don't need to create an instance of MyClass for i, because it is a class member, not an instance member.
Post a Comment for "Python Class Attribute Referencing"