Default path for files

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Jan 25 14:47:57 EST 2010


En Sun, 24 Jan 2010 15:04:48 -0300, Günther Dietrich  
<gd_usenet at spamfence.net> escribió:

> Rotwang <sg552 at hotmail.co.uk> wrote:
>
>>> Check out http://docs.python.org/library/os.html and the function
>>> chdir it is what you are looking for.
>>
>> Thank you. So would adding
>>
>> import os
>> os.chdir(<path>)
>>
>> to site.py (or any other module which is automatically imported during
>> initialisation) change the default location to <path> every time I used
>> Python?
>
> Don't change the library modules. It would catch you anytime when you
> expect it least.
>
> See for the environment variable PYTHONSTARTUP and the associated
> startup file.

sitecustomize.py would be a better place. PYTHONSTARTUP is only used when  
running in interactive mode.
Anyway, I'd do that explicitely on each script that requires it; after  
upgrading the Python version, or moving to another PC, those scripts would  
start failing...

-- 
Gabriel Genellina




More information about the Python-list mailing list