Reputation: 15
I am using python 3.6 version. I have 2 .py files as:
modbody.py
def test():
print("Statement goes here")
moduse.py
import modbody
test()
I am trying to execute moduse.py file in python interpreter using command "Python moduse.py" however, it gives me below error:
File "C:\users\Program\moduse.py", line 2, in test() NameError: name 'test' is not defined
Please help guide me how to execute the script and call the test function here? I have also tried adding a blank init.py file to solve this but with no luck. Please not all of my files are in same directory only.
Upvotes: 1
Views: 178
Reputation: 71570
I think you meant:
import modbody
modbody.test()
Or:
from modbody import test
test()
Or:
from modbody import *
test()
Upvotes: 3