Initializing interactive Python
Tomasz Rola
rtomek at ceti.pl
Sun Jul 24 16:36:44 EDT 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 24 Jul 2005 qwweeeit at yahoo.it wrote:
> 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:
I did this by using python's "-i" option. Under Unix/Linux environment,
you can set up a script like this:
- ------------ cut - cut - cut -----------
#!/usr/bin/python -i
# init interactive session
import someutils
someutils.init()
import sys
from blah.blaaah.blah import *
print "Hello there"
# Now it's ready and shows you a prompt, so you can abuse it freely ;)
- ----------- paste - paste - paste ---------
It should be possible to write similar script under any other sufficiently
developed OS. After executing a script, you are presented a prompt from
properly (i.e. the way you want it) initialised interpreter.
Regards,
Tomasz Rola
- --
** A C programmer asked whether computer had Buddha's nature. **
** As the answer, master did "rm -rif" on the programmer's home **
** directory. And then the C programmer became enlightened... **
** **
** Tomasz Rola mailto:tomasz_rola at bigfoot.com **
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
Charset: noconv
iQA/AwUBQuP75RETUsyL9vbiEQKtWgCgpIJS9nWo9tEf01QZACnoyCN5oSgAmgO0
a5+6CQiqEeT+58p/WZgjmlmw
=NVnJ
-----END PGP SIGNATURE-----
More information about the Python-list
mailing list