PYTHONSTARTUP ignored by python -i

David M. Cooke cookedm at
Wed Sep 13 22:59:33 CEST 2000

At some point, hzhu at (Huaiyu Zhu) wrote:

> Here's a simple thing that has bugged me for a while.
> I want to do something like
> python -i
> and get the effect of 
> python
> >>> from file import *
> However, it appears the .pythonrc in my $PYTHONSTARTUP is not read (which
> does the readline, command completion and history recall stuff).

from the man page:

       -i     When a script is passed as first argument or the -c
              option is used, enter interactive mode  after  exe­
              cuting the script or the command.  It does not read
              the $PYTHONSTARTUP file.  This  can  be  useful  to
              inspect  global  variables  or a stack trace when a
              script raises an exception.

> How do I achieve both results (.pythonrc and with one command line?

You could try this:

python -i -c "execfile('$PYTHONSTARTUP'); from file import *"

but then it's probably easier to type
>>> from file import *

David M. Cooke
cookedm at

More information about the Python-list mailing list