[IPython-dev] Re: rehash on Win*

Fernando Perez Fernando.Perez at colorado.edu
Thu Jun 24 13:44:43 CDT 2004


Daniel 'Dang' Griffith wrote:
>    >  > In particular, @rehash/x are very Unix-specific.  I don't know how to
>    >  deal
>    >  > with $PATH and how to make executability decisions under Windows,
>    >  which (I
>    >  > think) has a baroque extension-based mechanism for this.  If someone else
>    >  
>    >  Why don't you just make some well-known extensions executable? exe, bat,
>    >  cmd, py, pl? It's much better than nothing, and works for 99% of the cases.
> 
> You can get the extensions from os.environ['pathext']:
> 
> In [27]: import os
> In [28]: print os.environ['pathext'].split(';')
> ['.PYC', '.PY', '.COM', '.EXE', '.BAT', '.CMD', '.VBS', '.VBE', '.JS', '.JSE', '.WSF', '.WSH']
> 
> This list is in the order that the shell searches for them.  (I've added pyc and py
> to mine, so I can run python scripts without entering an extension (and regularly
> reconsider whether I should have pyc before or after py).)

Thanks.  Right now this is a settable string by the user, should I instead use 
this $pathext variable?  Which is the more natural approach for Windows users? 
  If $pathext is universal under windows, I could then leave the 
windows-specific code as:

try:
	ext=os.environ['pathext'].replace(';','|').replace('.','')
except KeyError:
	ext='exe|com|bat'

How does this sound?  I need Windows users' feedback to make this decision.

Cheers,

f




More information about the IPython-dev mailing list