Re: Corectly convert from %PATH%=c:\\X; c:\\a; b TO ['c:\\X', 'c:\\a; b']

2005-04-04 Thread Chirayu Krishnappa
I do agree that it is a crazy format - and am amazed that it works at the prompt. For the first case - you have a mismatched double quote for test2 at the end of the string. test2 should be r'c:\A\B;C\D;c:\program files\xyz' instead. For the 2nd case - my code swallowed the ';' it split on - so I

Re: Corectly convert from %PATH%=c:\\X; c:\\a; b TO ['c:\\X', 'c:\\a; b']

2005-04-04 Thread Chirayu Krishnappa
Its good to see what cpython did with the PATH. I now feel good about taking the simple approach. It would be crazy if that sort of quoting in the middle becomes something which works with too many applications - and others are expected to keep up with it. I guess I dont need to worry about unix

Re: Corectly convert from %PATH%=c:\\X; c:\\a; b TO ['c:\\X', 'c:\\a; b']

2005-04-03 Thread chirayuk
Michael Spencer wrote: chirayuk wrote: Hi, I am trying to treat an environment variable as a python list - and I'm sure there must be a standard and simple way to do so. I know that the interpreter itself must use it (to process $PATH / %PATH%, etc) but I am not able to find a simple

Re: Corectly convert from %PATH%=c:\\X; c:\\a; b TO ['c:\\X', 'c:\\a; b']

2005-04-03 Thread Jeff Epler
if your goal is to search for files on a windows-style path environment variable, maybe you don't want to take this approach, but instead wrap and use the _wsearchenv or _searchenv C library functions http://msdn.microsoft.com/library/en-us/vclib/html/_crt__searchenv.2c_._wsearchenv.asp

Re: Corectly convert from %PATH%=c:\\X; c:\\a; b TO ['c:\\X', 'c:\\a; b']

2005-04-03 Thread Michael Spencer
chirayuk wrote: However, I just realized that the following is also a valid PATH in windows. PATH=c:\A\B;C\D;c:\program files\xyz (The quotes do not need to cover the entire path) Too bad! What a crazy format! So here is my handcrafted solution. def WinPathList_to_PyList (pathList): pIter =

RE: Corectly convert from %PATH%=c:\\X; c:\\a; b TO ['c:\\X', 'c:\\a; b']

2005-04-03 Thread Chirayu Krishnappa
: Jeff Epler [mailto:[EMAIL PROTECTED] Sent: Sunday, April 03, 2005 8:02 AM To: chirayuk Cc: python-list@python.org Subject: Re: Corectly convert from %PATH%=c:\\X; c:\\a; b TO ['c:\\X', 'c:\\a; b'] if your goal is to search for files on a windows-style path environment variable, maybe you don't want

Re: Corectly convert from %PATH%=c:\\X; c:\\a; b TO ['c:\\X', 'c:\\a; b']

2005-04-03 Thread Jeff Epler
The C code that Python uses to find the initial value of sys.path based on PYTHONPATH seems to be simple splitting on the equivalent of os.pathsep. See the source file Python/sysmodule.c, function makepathobject(). for (i = 0; ; i++) { p = strchr(path, delim); // ; on

Corectly convert from %PATH%=c:\\X; c:\\a; b TO ['c:\\X', 'c:\\a; b']

2005-04-02 Thread chirayuk
Hi, I am trying to treat an environment variable as a python list - and I'm sure there must be a standard and simple way to do so. I know that the interpreter itself must use it (to process $PATH / %PATH%, etc) but I am not able to find a simple function to do so.

Re: Corectly convert from %PATH%=c:\\X; c:\\a; b TO ['c:\\X', 'c:\\a; b']

2005-04-02 Thread Michael Spencer
chirayuk wrote: Hi, I am trying to treat an environment variable as a python list - and I'm sure there must be a standard and simple way to do so. I know that the interpreter itself must use it (to process $PATH / %PATH%, etc) but I am not able to find a simple function to do so.