Telnet client using curses

Aquarius aquarius at kryogenix.albatross.co.uk
Tue Apr 18 20:53:43 EDT 2000


Having used Python for a few brief scripts (the sort of thing I used to
use Perl for :), I thought I'd try something a bit more ambitious, to
teach myself the language. What I decided on, because I need one, is a
telnet client. The key thing is that I'd like to use curses to give me
one input line into which text it typed, while data returned from the
connection goes into the window above. Something like TinyFugue.

Looking at telnetlib, it uses select to poll stdin. However, I'll be
getting user input using curses input functions, not input() or
raw_input(), so the user input doesn't go into stdin. Is the best way to
handle this:
1. get user input with the curses function and then somehow slip this
input into stdin, so it looks like it came from raw_input() or whatever?
Obviously, raw_input() gets its data into stdin, but it's a built-in
function, so I don't know how it does it :-)
2. write a file object which I feed data *into* from the curses input
function, and which then feeds that data back out when requested to do
so, and poll *that* instead of stdin?
3. A better solution?

If your answer is "3", some kind of suggestion as to the Right Way to do
it would be appreciated :-)

Aquarius

-- 
Well *done*, Aquarius -- a phrase we love typing because it makes us feel
like the boss-character from a 1980s Glen A Larson action series...
  NTK, http://www.ntk.net/index.cgi?back=archive99/now0618.txt&line=292#l




More information about the Python-list mailing list