Initializing interactive Python
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Sun Jul 24 07:30:09 EDT 2005
qwweeeit at yahoo.it 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 at 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.
>
>>>>import sys
>>>>x01=x02=0
>
>
> 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 at bibi bruno $ cat ~/.pythonrc.py
import sys
x01=x02=0
bruno at bibi bruno $ export PYTHONSTARTUP=~/.pythonrc.py
bruno at 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.
>>> sys
<module 'sys' (built-in)>
>>> x01
0
>>> x02
0
>>>
Easy as pie !-)
HTH
Bruno
More information about the Python-list
mailing list