PYTHONSTARTUP and the -i command line option

  • Thread starter Christopher Wood
  • Start date
C

Christopher Wood

Greetings all,

A quick query: as all sorts of stuff can be defined in a .pythonrc.py
file or similar and called at python startup using the PYTHONSTARTUP
environment variable, it's very useful and can enhance the interpreter
experience greatly.

However, executing a script using the -i command line option to put the
Python interpreter into 'interactive mode' after script termination is
also very useful.

But these two things won't play together, as (by design, it seems)
$PYTHONSTARTUP isn't read when the -i option is used, leaving me with an
unenhanced Python interpreter environment after after script execution.

Is the any way round this, other than editing all my scripts or manually
loading the .pythonrc.py script in the interpreter?

Thanks in advance for any hints!

Chris Wood
 
P

Peter Hansen

Christopher said:
But these two things won't play together, as (by design, it seems)
$PYTHONSTARTUP isn't read when the -i option is used, leaving me with an
unenhanced Python interpreter environment after after script execution.

Is the any way round this, other than editing all my scripts or manually
loading the .pythonrc.py script in the interpreter?

Modifying the contents of your .pythonrc script and therein setting the
PYTHONINSPECT environment variable via os.environ comes to mind.

-Peter
 
S

Simon Percivall

After entering the interpreter, you could do an execfile on the
..pythonrc file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top