Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > import

Reply
Thread Tools

import

 
 
jolly
Guest
Posts: n/a
 
      07-06-2007
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

 
Reply With Quote
 
 
 
 
Amit Khemka
Guest
Posts: n/a
 
      07-06-2007
On 7/6/07, jolly <> wrote:
> 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")


> Thanks


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.
 
Reply With Quote
 
 
 
 
Gary Herron
Guest
Posts: n/a
 
      07-06-2007
jolly wrote:
> 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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
to use import java.lang.* or import java.lang.Math or none at all? JPractitioner Java 13 02-24-2006 08:48 PM
XML Schema question - does "import" import elements? Vitali Gontsharuk XML 2 08-25-2005 07:33 PM
IMPORT STATIC; Why is "import static" file scope? Why not class scope? Paul Opal Java 12 10-10-2004 11:01 PM
GTK import doesn't import first time Dennis Python 2 08-18-2003 10:00 PM
import/from import question Artur M. Piwko Python 1 07-02-2003 07:04 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57