[Tutor] Press Enter to quit. Silently maybe.

Shashwat Anand anand.shashwat at gmail.com
Tue Mar 23 22:47:06 CET 2010


run this file (test.py) as:

def finish():
    print '\n', "bye", '\n'
    raw_input('Press Enter to quit: ')

finish()

$python -i test.py

A second approach could be:

def finish():
    import os, subprocess
    print '\n', "bye", '\n'
    raw_input('Press Enter to quit: ')
    subprocess.call('python')

finish()

$python test.py

bye

Press Enter to quit:
Python 2.6.1 (r261:67515, Jul  7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

A word of caution, am not using IDLE and preferably you should avoid it too.

~l0nwlf


On Wed, Mar 24, 2010 at 2:46 AM, bob gailer <bgailer at gmail.com> wrote:

> On 3/23/2010 4:47 PM, Wayne Watson wrote:
>
>> I use this code to quit a completed program. If no is selected for the
>> yes/no prompt, warning messages appear in the shell window.
>>
>
> What is the yes/no prompt? Is it in your program or is it a feature of
> IDLE?
>
> What are the warning messages?
>
>
>  I'm executing from IDLE. Is there a way to just return to the >>> prompt
>> there?
>>
>> def finish():
>>    print; print "Bye"
>>    print
>>    raw_input('Press Enter to quit')
>>    sys.exit()
>>
>>
>
> --
> Bob Gailer
> 919-636-4239
> Chapel Hill NC
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100324/004b4df1/attachment.html>


More information about the Tutor mailing list