class classA:
#saved as classA.py
def __init__(self):
print "class A"
printB()
def printB():
print "B"
>>> classA()
class A
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
classA()
File "C:\Documents and Settings\Owner\Desktop\timetable\classA.py", line 5, in __init__
printB()
NameError: global name 'printB' is not defined
Using the class above, I get the error saying that printB is not defined. It works when printB() is moved outside of the class. I want to have printB to be part of the class, like a static method. I tried adding "@staticmethod" above the 'def printB()' but that doesn't seem to work. Am I missing something?