Can anyone please help me with this ?
I am moving on using PyDev Aptana for developing python codes. Here is my project structure under PyDev IDE :
/testProject
/src
/testModule
__init__.py
testMod.py
main.py
testMod.py file :
def test(n):
print "echo"+n
main.py file :
import testModule
testModule.test(4)
When I try to run this in PyDev , it gave me this error at main.py , line 2 ( where test(4) is called):
AttributeError: 'module' object has no attribute 'test'
I change main.py to :
import testModule.test
testModule.test(4)
still gives me error 'module' object not callable!
What is wrong with this ??
Well, this is basically because there is no method
test()intestModule. In fact, yourtestModuleis not module, but is a package, whiletestModis a module intestModulepackage.So, with your structure, the following will work:
See http://docs.python.org/tutorial/modules.html for more details