saved sys.path

Eric S. Johansson esj at harvee.org
Mon Nov 1 23:20:56 EST 2004


Alex Martelli wrote:
> The modifications to sys.path performed by .pth files are visible to all
> applications.  A single application may (however it chooses to do so)
> find out or determine a path it wants only for its own imports, and
...historical record deleted
 >  Python is not particularly
> different, from the point of view of "where does an app find its own
> configuration information", from most other languages.

from historical perspective, I understand and appreciate your 
explanation.  However, just because it's historically accurate, does it 
mean we should keep doing things the same old way?

In natlink, Joel Gould's python extensions to NaturallySpeaking, he made 
each speech recognition grammar environment either globally accessible 
or command specific.  He used the expedient technique of using the same 
name as the command for the Python file containing the grammar 
associated with that command.  He also used another simple technique, 
prefacing a filename with an "_" to indicate a globally visible grammar 
and code.  Turns out this was a frightfully useful technique as it 
allows for partitioning grammars.  Unfortunately, because of path 
problems it's difficult to share modules between various grammars.

It seems to me that a similar technique would serve for our purposes.  A 
file, command_name.path, would contain all of the search as necessary 
for a command called by the same name.  this technique would allow for a 
common platform independent method of finding application-specific 
modules and automatically generated paths for site-specific 
relocation/configuration.

As I write this, it occurs to me that a provisional body of code to 
experiment with the technique would possibly serve the community well. 
  I will generate something tomorrow for public scrutiny as I am up past 
my bedtime.  Thank you for triggering the idea.




More information about the Python-list mailing list