import

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jolly

    #1

    import

    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

  • Amit Khemka

    #2
    Re: import

    On 7/6/07, jolly <jemnader@gmail .comwrote:
    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.

    Comment

    • Gary Herron

      #3
      Re: import

      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.


      Comment

      Working...