#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Sweden
    Posts
    20
    Rep Power
    0

    MS-DOS Help with Python


    Hey,

    In the Win 2000 Pro / Win Xp version there is a known error with the MS-Dos Prompt window, for example when I code something in Python, and I want to test the program, I double click the *.py file and the MS-Dos Window just open quick and close down automatically like a flash. Now I know there is something I can do about it but I can't remember how, can anyone help me out on this?

    Thanks in advance,
    Micheal
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    174
    Rep Power
    11

    pythonw.exe not python.exe


    It's in the help files, but like the title says, just use pythonw.exe and not python.exe and the flashy boxy thingy will go away...

    Cheers
    sf2k
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    136
    Rep Power
    11
    Zopyrus:

    Either you can do this:

    Code:
    import os
    <your python code here>
    os.system("PAUSE")
    or you can do this:

    Code:
    import time
    <your python code here>
    time.sleep(1000000000)

    or you can do this:


    Code:
    import thread
    import time
    
    def yourfunction(f):
        print "My python code goes in this function"
    
    thread.start_new_thread(yourfunction, (1,))
    
    while 1:
        time.sleep(1)

    and there are probably other ways too.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
    In the Win 2000 Pro / Win Xp version there is a known error with the MS-Dos Prompt window
    It isn't an error, it's standard behaviour - when a program finishes running, it closes.


    You could add a line at the end:

    Code:
    tmp = raw_input("Program done, press enter to exit...")
    Or open the command prompt properly (start -> run -> cmd -> OK) and launch your program from that.

    just use pythonw.exe and not python.exe and the flashy boxy thingy will go away...
    Yes, if your goal is to get rid of the command prompt, rename your file to .pyw, but that wont help you read the output...
  8. #5
  9. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Originally Posted by sfb
    ...You could add a line at the end:

    Code:
    tmp = raw_input("Program done, press enter to exit...")
    Just a note that you don't need to assign the return value of raw_input() to anything, although you can but it would generally be considered a little pointless; you would usually just write: raw_input('Leaving message').

    Still, I would be inclined to run Python programs from the command line as sbf mentioned rather than double kicking them since it gives you so much more control .

    Mark.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo