I am very new to python programming and writing a simple helloworld program using python 3.3 for windows environmentoment. The helloworld program is saved as hello.py. So how can I use it in another module. I tried sys.path.append and gave the path to my save file but it didn't work. Can someone tell me that I need to set the environment variable in windows xp
Thanks.
Use this method:
import sys
then
sys.path.insert(0,"X")
Where X is the directory from which you want to import.
X
After that, you just need to import your custom module:
import X
That's all.
There is a DIR directory containing our module X : /DIR/X
DIR
/DIR/X
import sys sys.path.insert(0,"DIR") import X
Imports a module, for example. X = hello .
hello
If you are trying to create your hello.py module, you need to create a file called __init.py__ in the hello.py folder.
hello.py
__init.py__
Take a look at the Python documentation here .