473,372 Members | 1,019 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

Python Path Dictionary

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 '07 #1
4 1983
ai********@yahoo.com 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']
Aug 21 '07 #2
On 21 Aug, 17:42, Gary Herron <gher...@islandtraining.comwrote:
aine_ca...@yahoo.com 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 '07 #3
On 8/21/07, ai********@yahoo.com <ai********@yahoo.comwrote:
On 21 Aug, 17:42, Gary Herron <gher...@islandtraining.comwrote:
aine_ca...@yahoo.com 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.
Aug 21 '07 #4
On 21 Aug, 21:45, "Chris Mellon" <arka...@gmail.comwrote:
On 8/21/07, aine_ca...@yahoo.com <aine_ca...@yahoo.comwrote:


On 21 Aug, 17:42, Gary Herron <gher...@islandtraining.comwrote:
aine_ca...@yahoo.com 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 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: M.E.Farmer | last post by:
Hello c.l.py!, I have just finished this and decided to share. PySourceColor is a module to convert Python source into colored html. Yes it has been done before, but I like this better:) You can...
10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
5
by: EP | last post by:
This inquiry may either turn out to be about the suitability of the SHA-1 (160 bit digest) for file identification, the sha function in Python ... or about some error in my script. Any insight...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 349 open ( +7) / 3737 closed (+25) / 4086 total (+32) Bugs : 939 open (-12) / 6648 closed (+60) / 7587 total (+48) RFE : 249 open...
0
by: Joe Goldthwaite | last post by:
Thanks Guilherme. That helped. I guess I was thinking that pysqlite would automatically come with some version of sqlite. The fact that it doesn't is what was causing me to get the strange...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.