Initializing interactive Python

Discussion in 'Python' started by qwweeeit@yahoo.it, Jul 24, 2005.

  1. Guest

    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.
    , Jul 24, 2005
    #1
    1. Advertising

  2. On Sun, Jul 24, 2005 at 03:26:06AM -0700, 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/
    Thanos Tsouanas, Jul 24, 2005
    #2
    1. Advertising

  3. 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
    Bruno Desthuilliers, Jul 24, 2005
    #3
  4. Guest

    Hi Bruno,
    thank you..."Easy as pie !-)"
    Bye.
    , Jul 24, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. WJ
    Replies:
    2
    Views:
    483
  2. Christoph Becker-Freyseng

    dumping command-history in python interactive mode

    Christoph Becker-Freyseng, Jul 17, 2003, in forum: Python
    Replies:
    3
    Views:
    391
    Pedro Werneck
    Jul 18, 2003
  3. POYEN OP Olivier (DCL)

    RE: dumping command-history in python interactive mode

    POYEN OP Olivier (DCL), Jul 18, 2003, in forum: Python
    Replies:
    0
    Views:
    388
    POYEN OP Olivier (DCL)
    Jul 18, 2003
  4. JT
    Replies:
    5
    Views:
    2,103
    Harald Massa
    Apr 17, 2004
  5. Ashot
    Replies:
    22
    Views:
    4,202
    Fernando Perez
    Feb 8, 2005
Loading...

Share This Page