Caution newbie question: python window to stay open ?

Discussion in 'Python' started by mkengel, Nov 22, 2006.

  1. mkengel

    mkengel Guest

    Caution: newbie question

    I am using python 2.4.3-11 on Windows XP.
    Problem: Python window closes immediately after executing a *.py file
    (e.g. containing a "print..." command.
    What do I have to do to keep it open to see the results ?

    "Interactive window" stays open.

    Thank you.
    Michael
     
    mkengel, Nov 22, 2006
    #1
    1. Advertisements

  2. mkengel

    Guest

    mkengel wrote:

    > Caution: newbie question



    If you're pretty sure it's a common newbie question, then begin by
    going to the Google repository at:

    http://groups.google.com/group/comp.lang.python

    Search in the box at upper right, on, say, keep cmd window open, or
    keep dos window open.

    Like so:

    http://tinyurl.com/yfbtgx

    And you'll have answers going all the way back to antiquity.

    rd
     
    , Nov 22, 2006
    #2
    1. Advertisements

  3. mkengel wrote:

    > Caution: newbie question


    If you're pretty sure it's a common newbie question, then begin by
    going to the Google repository at:

    http://groups.google.com/group/comp.lang.python

    Search in the box at upper right, on, say, keep cmd window open, or
    keep dos window open.

    Like so:

    http://tinyurl.com/yfbtgx

    And you'll have answers going all the way back to antiquity.

    rd
     
    BartlebyScrivener, Nov 22, 2006
    #3
  4. mkengel wrote:

    > Problem: Python window closes immediately after executing a *.py file
    > (e.g. containing a "print..." command.
    > What do I have to do to keep it open to see the results ?


    Simple scripts that print to a console, or read from it, works best if
    you run them from a standard Command Prompt window.

    If you just click on a Python script in the explorer, Windows will
    create a temporary command window, and remove it when the program is
    done. This is standard Windows behaviour; to get around this in a
    general way, you need to write GUI-oriented Python programs (using e.g.
    Tkinter or wxPython), and run them using the "pythonw.exe" runtime.

    For simpler scripts, you can also add

    raw_input("Press return to close this window...")

    to the end of the script.

    For tips on running Python programs from the command prompt, this page
    might also be helpful:

    http://effbot.org/pyfaq/how-do-i-run-a-python-program-under-windows

    </F>
     
    Fredrik Lundh, Nov 22, 2006
    #4
  5. mkengel

    jim-on-linux Guest

    Michael,

    put this at the top of your code. After the window
    closes read the testLog.out file. It may give you
    a clue as to what is happening.

    sys.stdout = open('testLog.out', 'w')


    jim-on-linux
    http://www.inqvista.com


    On Tuesday 21 November 2006 22:20, mkengel wrote:
    > Caution: newbie question
    >
    > I am using python 2.4.3-11 on Windows XP.
    > Problem: Python window closes immediately after
    > executing a *.py file (e.g. containing a
    > "print..." command. What do I have to do to
    > keep it open to see the results ?
    >
    > "Interactive window" stays open.
    >
    > Thank you.
    > Michael
     
    jim-on-linux, Nov 22, 2006
    #5
  6. mkengel

    sf_cesario659

    Joined:
    Jun 26, 2009
    Messages:
    1
    Likes Received:
    0
    Use the /K option

    the cmd.exe program has /K switch which holds the window open by returning to a command prompt.


    Some text editors will have the ability to configure tools, so you can modify something like this:

    C:\Windows\System32\cmd.exe /K X:\Python2.6.2\python.exe "%FILE%"

    for your own system
     
    sf_cesario659, Jun 26, 2009
    #6
    1. Advertisements

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. =?Utf-8?B?RHVzdGluIElJLg==?=

    make a browser window stay on top window handle?

    =?Utf-8?B?RHVzdGluIElJLg==?=, Aug 18, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    991
    Mark Rae
    Aug 18, 2004
  2. Sony Music CDs install Malware

    Caution SONY Music CDs have trojan Malware

    Sony Music CDs install Malware, Nov 3, 2005, in forum: C++
    Replies:
    80
    Views:
    1,834
    kurt wismer
    Nov 29, 2005
  3. Replies:
    1
    Views:
    839
  4. Yakov
    Replies:
    22
    Views:
    930
  5. Replies:
    5
    Views:
    456
    Bruno Desthuilliers
    May 13, 2008
  6. Bobby Edward

    How get modal window to stay open?!!!

    Bobby Edward, Oct 8, 2008, in forum: ASP .Net
    Replies:
    3
    Views:
    840
    Bobby Edward
    Oct 9, 2008
  7. Paul
    Replies:
    2
    Views:
    253
  8. PC HUA
    Replies:
    2
    Views:
    666
    PC HUA
    May 19, 2004
Loading...