How to use import statement for custom modules in Python

python-3.x

I am very new to python programming and writing simple helloworld program by using python 3.3 on windows environoment.The helloworld program is saved as hello.py. So how can i use it in another module. I tried sys.path.append and give path of my save file but its not working.
Can somebody tell me do i have to set Environment variable in windows xp

Thanks.

Best Answer

Use this way:

import sys

then:

sys.path.insert(0,"X")

Where X is the directory you want to import from.

After that you just need to import your custom module:

import X

Thats all.

Related Topic