Initializing interactive Python

Q

qwweeeit

Hi all,
is it possible to enter an interactive session and automatically
do some initialization?
I explain better:
I want that when I start interactive Python on a console (I use Linux)
two command lines be executed automatically:

Python 2.3.4 (#2, Aug 19 2004, 15:49:40)
[GCC 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
I would like not to have to write anything at the prompt >>> to run
the two commands, but be ready to start the interactive session.
Bye.
 
T

Thanos Tsouanas

Hi all,
is it possible to enter an interactive session and automatically
do some initialization?

set the enviroment variable PYTHONSTARTUP to point to a startup.py of
your own, where you put all your initializations..

HTH
 
B

Bruno Desthuilliers

(e-mail address removed) a écrit :
Hi all,
is it possible to enter an interactive session and automatically
do some initialization?
I explain better:
I want that when I start interactive Python on a console (I use Linux)
two command lines be executed automatically:

bruno@bibi bruno $ python -h
(snip)
Other environment variables:
PYTHONSTARTUP: file executed on interactive startup (no default)
(snip)
Python 2.3.4 (#2, Aug 19 2004, 15:49:40)
[GCC 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)] on linux2
Type "help", "copyright", "credits" or "license" for more information.


I would like not to have to write anything at the prompt >>> to run
the two commands, but be ready to start the interactive session.
Bye.

bruno@bibi bruno $ cat ~/.pythonrc.py
import sys
x01=x02=0
bruno@bibi bruno $ export PYTHONSTARTUP=~/.pythonrc.py
bruno@bibi bruno $ python
Python 2.4.1 (#1, Jul 23 2005, 00:37:37)
[GCC 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)] on
linux2
Type "help", "copyright", "credits" or "license" for more information.
Easy as pie !-)

HTH
Bruno
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top