tags:

views:

102

answers:

3
import sys

print (sys.platform)
print (2 ** 100)
input('press Enter to exit')

Suppose I wanted to use the number 1 as the button that must be pressed to exit. How would I go about doing this?

+1  A: 

Something like this will do what you want:

while(raw_input('Press "1" to exit.') != '1'):
    pass
Tyson
But you need to enter and extra "Enter", since input is line buffered. Even if the question is not very clear, I assumed he wants to read a single keystroke, so I suggested the link below...
Mapio
+2  A: 

Something like this?

http://mail.python.org/pipermail/python-list/1999-October/014262.html

Not so clean, but doable.

Mapio
Gone. Use this: http://web.archive.org/web/20080104144812/http://mail.python.org/pipermail/python-list/1999-October/014262.html
Teddy
+2  A: 

If you're building a command line app, why not use one of the libraries that help you build one.

For example:

Tom Feiner