Newbie: Why Does This Work This Way...Global Variables And The Signal Module....

John Branthoover jbranthoover at yahoo.com.NOSPAM
Fri Sep 14 15:00:59 EDT 2001


Hey thanks Ingacio,
    This works great.  Pressing enter is much better than CTRL C.  I don't
know much about the select(),  but I read  in another article that it is a
line orientated device.  The articled told how to put it into a charter mode
using TERMOIS and termios modules.  Unfortunately I do not have access to
the termios module.  I would like to have an "any key" function.

    I am basically a hardware guy and I am in the process of writing
checkout software for a board that I have designed.  The Python installation
that I am working with was ported over by one of our software engineers.  I
had him look into getting ncurses to compile but after a half of a day he
gave up.  He has more important issues to deal with than getting me access
to pretty colors, windows and other curses goodies.  Which he does.  I have
Linux installation at home and have played with the Python curses module and
I know what I am missing.

    Any way thanks again for your help......


"Ignacio Vazquez-Abrams" <ignacio at openservices.net> wrote in message
news:mailman.1000434075.23039.python-list at python.org...
> 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