import

J

jolly

Hey guys,

I'm rather new to python and i'm have trouble(as usual)

I want to know if it is possible to change where 'import' looks....
this will save me clogging up my python directory

Thanks
 
A

Amit Khemka

Hey guys,

I'm rather new to python and i'm have trouble(as usual)

Hope it becomes un-usual with Python !
I want to know if it is possible to change where 'import' looks....
this will save me clogging up my python directory

Yes. You can tell python where all to look for importing modules.

import sys
sys.path.append("/this/is/my/modules/path")


Welcome !

cheers,

--
----
Amit Khemka
website: www.onyomo.com
wap-site: www.owap.in
Home Page: www.cse.iitd.ernet.in/~csd00377

Endless the world's turn, endless the sun's Spinning, Endless the quest;
I turn again, back to my own beginning, And here, find rest.
 
G

Gary Herron

jolly said:
Hey guys,

I'm rather new to python and i'm have trouble(as usual)

I want to know if it is possible to change where 'import' looks....
this will save me clogging up my python directory

Thanks
Easily done. The value of sys.path is a list of directories that import
looks through to satisfy an import. Just import sys and append a new
directory to sys.path.

import sys
sys.path.append('/your/directory/of/importable/modules')
// Then import code from your directory.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top