Re: Initializing interactive Python

2005-07-24 Thread Tomasz Rola
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 24 Jul 2005 [EMAIL PROTECTED] 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:[EMAIL PROTECTED] **


-BEGIN PGP SIGNATURE-
Version: PGPfreeware 5.0i for non-commercial use
Charset: noconv

iQA/AwUBQuP75RETUsyL9vbiEQKtWgCgpIJS9nWo9tEf01QZACnoyCN5oSgAmgO0
a5+6CQiqEeT+58p/WZgjmlmw
=NVnJ
-END PGP SIGNATURE-


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Initializing interactive Python

2005-07-24 Thread qwweeeit
Hi Bruno,
thank you..."Easy as pie !-)"
Bye.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Initializing interactive Python

2005-07-24 Thread Thanos Tsouanas
On Sun, Jul 24, 2005 at 03:26:06AM -0700, [EMAIL PROTECTED] wrote:
> 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

-- 
Thanos Tsouanas  .: My Music: http://www.thanostsouanas.com/
http://thanos.sians.org/ .: Sians Music: http://www.sians.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Initializing interactive Python

2005-07-24 Thread Bruno Desthuilliers
[EMAIL PROTECTED] 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:

[EMAIL PROTECTED] 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.

[EMAIL PROTECTED] bruno $ cat ~/.pythonrc.py
import sys
x01=x02=0
[EMAIL PROTECTED] bruno $ export PYTHONSTARTUP=~/.pythonrc.py
[EMAIL PROTECTED] 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

 >>> x01
0
 >>> x02
0
 >>>

Easy as pie !-)

HTH
Bruno

-- 
http://mail.python.org/mailman/listinfo/python-list


Initializing interactive Python

2005-07-24 Thread 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.
>>> 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.

-- 
http://mail.python.org/mailman/listinfo/python-list