class - Regarding classes in python -
i have basic question python classes. access
class member defined in 1 python file across different files. here code:
i have 1 python file class_a.py
:
class a: def hello(self): self.a=12 print "printing value class_1",self.a
here code of class_b.py file
import class_a def func_b(): instance = class_a.a() instance.hello() func_b()
when execute, shows:
typeerror: hello() takes no arguments (1 given).
basically i'm trying accessing class members defined in class_a.py
creating instance class inside function func_b
defined
in python file class_b.py
. right?
i think problem indentation in class a
:
class a: def hello(self): self.a = 12 print "printing value class_1", self.a
aside: take pep8
style guide.
Comments
Post a Comment