Python Path Dictionary

Discussion in 'Python' started by aine_canby@yahoo.com, Aug 21, 2007.

  1. Guest

    Hi,

    Do the Python Paths come in the form of a dictionary where I can
    access a particular path my its key in the registry?

    For example, in PythonWin Tools>>Edit Python Paths shows the name as
    well of the address of each path

    Thanks,

    Aine
    , Aug 21, 2007
    #1
    1. Advertising

  2. Gary Herron Guest

    wrote:
    > Hi,
    >
    > Do the Python Paths come in the form of a dictionary where I can
    > access a particular path my its key in the registry?
    >
    > For example, in PythonWin Tools>>Edit Python Paths shows the name as
    > well of the address of each path
    >
    > Thanks,
    >
    > Aine
    >
    >

    If by "Python Paths" you mean the list of directories searched when
    doing an import, then it is a list (not a dictionary and you can access
    it as sys.path.

    Here it is on both my Linux and Windows systems:

    >>> import sys
    >>> sys.path

    ['', '/usr/lib/portage/pym', '/usr/lib/python25.zip',
    '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2',
    '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload',
    '/usr/lib/python2.5/site-packages',
    '/usr/lib/python2.5/site-packages/Numeric',
    '/usr/lib/python2.5/site-packages/PIL',
    '/usr/lib/python2.5/site-packages/gtk-2.0']

    >>> import sys
    >>> sys.path

    ['', 'C:\\WINDOWS\\system32\\python24.zip', 'C:\\cygwin\\home\\Gary',
    'c:\\python24\\DLLs', 'c:\\python24\\lib',
    'c:\\python24\\lib\\plat-win', 'c:\\python24\\lib\\lib-tk',
    'c:\\python24', 'c:\\python24\\lib\\site-packages',
    'c:\\python24\\lib\\site-packages\\Numeric',
    'c:\\python24\\lib\\site-packages\\PIL',
    'c:\\python24\\lib\\site-packages\\gtk-2.0',
    'c:\\python24\\lib\\site-packages\\win32',
    'c:\\python24\\lib\\site-packages\\win32\\lib',
    'c:\\python24\\lib\\site-packages\\Pythonwin']
    Gary Herron, Aug 21, 2007
    #2
    1. Advertising

  3. Guest

    On 21 Aug, 17:42, Gary Herron <> wrote:
    > wrote:
    > > Hi,

    >
    > > Do the Python Paths come in the form of a dictionary where I can
    > > access a particular path my its key in the registry?

    >
    > > For example, in PythonWin Tools>>Edit Python Paths shows the name as
    > > well of the address of each path

    >
    > > Thanks,

    >
    > > Aine

    >
    > If by "Python Paths" you mean the list of directories searched when
    > doing an import, then it is a list (not a dictionary and you can access
    > it as sys.path.
    >
    > Here it is on both my Linux and Windows systems:
    >
    > >>> import sys
    > >>> sys.path

    >
    > ['', '/usr/lib/portage/pym', '/usr/lib/python25.zip',
    > '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2',
    > '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload',
    > '/usr/lib/python2.5/site-packages',
    > '/usr/lib/python2.5/site-packages/Numeric',
    > '/usr/lib/python2.5/site-packages/PIL',
    > '/usr/lib/python2.5/site-packages/gtk-2.0']
    >
    > >>> import sys
    > >>> sys.path

    >
    > ['', 'C:\\WINDOWS\\system32\\python24.zip', 'C:\\cygwin\\home\\Gary',
    > 'c:\\python24\\DLLs', 'c:\\python24\\lib',
    > 'c:\\python24\\lib\\plat-win', 'c:\\python24\\lib\\lib-tk',
    > 'c:\\python24', 'c:\\python24\\lib\\site-packages',
    > 'c:\\python24\\lib\\site-packages\\Numeric',
    > 'c:\\python24\\lib\\site-packages\\PIL',
    > 'c:\\python24\\lib\\site-packages\\gtk-2.0',
    > 'c:\\python24\\lib\\site-packages\\win32',
    > 'c:\\python24\\lib\\site-packages\\win32\\lib',
    > 'c:\\python24\\lib\\site-packages\\Pythonwin']


    Thanks.

    Yeah, that's exactly what I'm talking about, but I don't want the
    list, I want to access a certain path by name. I'm guessing I'm going
    to have to write a function to do this that reads the value from the
    registry.
    , Aug 21, 2007
    #3
  4. Chris Mellon Guest

    On 8/21/07, <> wrote:
    > On 21 Aug, 17:42, Gary Herron <> wrote:
    > > wrote:
    > > > Hi,

    > >
    > > > Do the Python Paths come in the form of a dictionary where I can
    > > > access a particular path my its key in the registry?

    > >
    > > > For example, in PythonWin Tools>>Edit Python Paths shows the name as
    > > > well of the address of each path

    > >
    > > > Thanks,

    > >
    > > > Aine

    > >
    > > If by "Python Paths" you mean the list of directories searched when
    > > doing an import, then it is a list (not a dictionary and you can access
    > > it as sys.path.
    > >
    > > Here it is on both my Linux and Windows systems:
    > >
    > > >>> import sys
    > > >>> sys.path

    > >
    > > ['', '/usr/lib/portage/pym', '/usr/lib/python25.zip',
    > > '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2',
    > > '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload',
    > > '/usr/lib/python2.5/site-packages',
    > > '/usr/lib/python2.5/site-packages/Numeric',
    > > '/usr/lib/python2.5/site-packages/PIL',
    > > '/usr/lib/python2.5/site-packages/gtk-2.0']
    > >
    > > >>> import sys
    > > >>> sys.path

    > >
    > > ['', 'C:\\WINDOWS\\system32\\python24.zip', 'C:\\cygwin\\home\\Gary',
    > > 'c:\\python24\\DLLs', 'c:\\python24\\lib',
    > > 'c:\\python24\\lib\\plat-win', 'c:\\python24\\lib\\lib-tk',
    > > 'c:\\python24', 'c:\\python24\\lib\\site-packages',
    > > 'c:\\python24\\lib\\site-packages\\Numeric',
    > > 'c:\\python24\\lib\\site-packages\\PIL',
    > > 'c:\\python24\\lib\\site-packages\\gtk-2.0',
    > > 'c:\\python24\\lib\\site-packages\\win32',
    > > 'c:\\python24\\lib\\site-packages\\win32\\lib',
    > > 'c:\\python24\\lib\\site-packages\\Pythonwin']

    >
    > Thanks.
    >
    > Yeah, that's exactly what I'm talking about, but I don't want the
    > list, I want to access a certain path by name. I'm guessing I'm going
    > to have to write a function to do this that reads the value from the
    > registry.
    >


    The elements of the path don't have names - they are a list of
    directories. You are mistaking Pythonwins configuration options (like
    where it searches for modules) for the python path.

    Note that the registry entry "PythonPath" (which is not respected by
    Python, but used by Pythonwin to override the default python path) is
    a semi-colon separated list, not a series of keys.
    Chris Mellon, Aug 21, 2007
    #4
  5. Guest

    On 21 Aug, 21:45, "Chris Mellon" <> wrote:
    > On 8/21/07, <> wrote:
    >
    >
    >
    >
    >
    > > On 21 Aug, 17:42, Gary Herron <> wrote:
    > > > wrote:
    > > > > Hi,

    >
    > > > > Do the Python Paths come in the form of a dictionary where I can
    > > > > access a particular path my its key in the registry?

    >
    > > > > For example, in PythonWin Tools>>Edit Python Paths shows the name as
    > > > > well of the address of each path

    >
    > > > > Thanks,

    >
    > > > > Aine

    >
    > > > If by "Python Paths" you mean the list of directories searched when
    > > > doing an import, then it is a list (not a dictionary and you can access
    > > > it as sys.path.

    >
    > > > Here it is on both my Linux and Windows systems:

    >
    > > > >>> import sys
    > > > >>> sys.path

    >
    > > > ['', '/usr/lib/portage/pym', '/usr/lib/python25.zip',
    > > > '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2',
    > > > '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload',
    > > > '/usr/lib/python2.5/site-packages',
    > > > '/usr/lib/python2.5/site-packages/Numeric',
    > > > '/usr/lib/python2.5/site-packages/PIL',
    > > > '/usr/lib/python2.5/site-packages/gtk-2.0']

    >
    > > > >>> import sys
    > > > >>> sys.path

    >
    > > > ['', 'C:\\WINDOWS\\system32\\python24.zip', 'C:\\cygwin\\home\\Gary',
    > > > 'c:\\python24\\DLLs', 'c:\\python24\\lib',
    > > > 'c:\\python24\\lib\\plat-win', 'c:\\python24\\lib\\lib-tk',
    > > > 'c:\\python24', 'c:\\python24\\lib\\site-packages',
    > > > 'c:\\python24\\lib\\site-packages\\Numeric',
    > > > 'c:\\python24\\lib\\site-packages\\PIL',
    > > > 'c:\\python24\\lib\\site-packages\\gtk-2.0',
    > > > 'c:\\python24\\lib\\site-packages\\win32',
    > > > 'c:\\python24\\lib\\site-packages\\win32\\lib',
    > > > 'c:\\python24\\lib\\site-packages\\Pythonwin']

    >
    > > Thanks.

    >
    > > Yeah, that's exactly what I'm talking about, but I don't want the
    > > list, I want to access a certain path by name. I'm guessing I'm going
    > > to have to write a function to do this that reads the value from the
    > > registry.

    >
    > The elements of the path don't have names - they are a list of
    > directories. You are mistaking Pythonwins configuration options (like
    > where it searches for modules) for the python path.
    >
    > Note that the registry entry "PythonPath" (which is not respected by
    > Python, but used by Pythonwin to override the default python path) is
    > a semi-colon separated list, not a series of keys.- Dölj citerad text -
    >
    > - Visa citerad text -


    Your right with regard to Python Win! Although, it can be both a semi-
    colon seperated list and/or a set of keys. On my PC I have a default
    key under python paths (with a list of paths), plus a set of keys with
    their own individul paths. I can therefore install my python code in
    any directory and manipulate these keys to find the modules I need.
    , Aug 22, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ron Adam
    Replies:
    3
    Views:
    447
    Ron Adam
    Aug 2, 2005
  2. Ilias Lazaridis
    Replies:
    6
    Views:
    437
    Ilias Lazaridis
    Feb 21, 2006
  3. james_027
    Replies:
    1
    Views:
    322
    Marc 'BlackJack' Rintsch
    Aug 22, 2007
  4. Navkirat Singh
    Replies:
    6
    Views:
    3,027
    Navkirat Singh
    Jul 29, 2010
  5. Chris Rebert
    Replies:
    0
    Views:
    521
    Chris Rebert
    Jul 29, 2010
Loading...

Share This Page