Echo console to a device (and vice-versa)?

Peter Otten __peter__ at web.de
Fri Oct 3 05:49:35 EDT 2003


Francis Avila wrote:

>         try:
>             ttybuf = os.read(ttyfdout, 1)
>         except OSError, err:
>             if err == EAGAIN:
>                 pass
>         else:
>             os.write(stdout, ttybuf)

Well, admitting that I don't have any idea what you want to do, the above
code silences *any* OSError, i. e.

if err == EAGAIN:
    pass

is a NOOP. If you want to catch only EAGAIN, you might consider

try:
    ttybuf = os.read(ttyfdout, 1)
except OSError, err:
    if err != EAGAIN:
        raise
else:
    os.write(stdout, ttybuf)

instead.

Peter





More information about the Python-list mailing list