Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Initializing interactive Python

Reply
Thread Tools

Initializing interactive Python

 
 
qwweeeit@yahoo.it
Guest
Posts: n/a
 
      07-24-2005
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.

 
Reply With Quote
 
 
 
 
Thanos Tsouanas
Guest
Posts: n/a
 
      07-24-2005
On Sun, Jul 24, 2005 at 03:26:06AM -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) 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/
 
Reply With Quote
 
 
 
 
Bruno Desthuilliers
Guest
Posts: n/a
 
      07-24-2005
(E-Mail 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.
>
>>>>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@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.
>>> sys

<module 'sys' (built-in)>
>>> x01

0
>>> x02

0
>>>


Easy as pie !-)

HTH
Bruno

 
Reply With Quote
 
qwweeeit@yahoo.it
Guest
Posts: n/a
 
      07-24-2005
Hi Bruno,
thank you..."Easy as pie !-)"
Bye.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Start a python interactive shell from python. Bo Peng Python 2 01-26-2006 06:46 PM
Interactive/Non-interactive ASPX ? WJ ASP .Net 2 02-26-2005 02:54 AM
IDLE history, Python IDE, and Interactive Python with Vim Ashot Python 22 02-08-2005 05:38 AM
non Interactive and Interactive AAH Computer Support 0 01-09-2005 04:09 PM
Interactive and non interactive AAH Computer Support 1 01-09-2005 04:01 PM



Advertisments