Newbie: Why Does This Work This Way...Global Variables And The Signal Module....
Ignacio Vazquez-Abrams
ignacio at openservices.net
Thu Sep 13 22:19:59 EDT 2001
On Fri, 14 Sep 2001, John Branthoover wrote:
> OK, that makes sense. Is there not away to define a global variable
> once for all of the functions in the module?
Nope. At least not that I know of.
> Or better yet, is there a better way to break out of a endless loop.
> The loop will display some values continuously. I want to be able to get
> out of this loop and go back to a main menu. I am working on an Lynx box
> (not Linux) with no GUI or even curses support.
The following will run until you press enter:
---
import sys, select
def run():
while 1:
e=select.select([sys.stdin], [], [], 0)
if not e==([], [], []):
c=sys.stdin.read(1)
if c=='\n':
break
print "You can't catch me, I'm the gingerbread man!"
run()
print "D'oh! You caught me!"
---
There's no reason why it couldn't catch another character if the select()
function returns on any keypress, which it doesn't seem to on Linux :/
Also, if you can put a termcap/terminfo into the Lynx box, you may be able to
get (n)curses working.
--
Ignacio Vazquez-Abrams <ignacio at openservices.net>
More information about the Python-list
mailing list