I am trying to make a python script that works so:
I've got a main file that import another file, which is a class with functions inside it. The main file calls a function in the module, here it works all well, but when the def inside the module calls another def in the main again, I get an error.
For example, in main.py I've got this
from module import *
module = Example()
def foo():
module.foo2()
def foo3():
print "here is the problem"
if(__name__ == "__main__"):
foo()
In module.py I've got:
class Example():
def foo2(self):
foo3()
foo2 is called perfectly, but when I try to call foo3() I get a NameError (global name 'foo3' is not defined). I know I should import it somehow but I don't know how to do it.
Last thing: I am quite new to python so please explain good :-) Thanks
if(if __name__ == "__main__"):is a typo, and the outerif(...)should be removed?