I am still learning python, however in 'Learning Python' they give an
example about how to redefine the print function using sys.stdout
methods and say one can do the same with sys.stdin. So I thought it
might be easy!
Looks like no, or maybe I need to contact one of the authors and beg
them to give an example!
Thank you for your help!
>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<
On 11/6/99, 11:57:31 AM, Andreas Degert <[EMAIL PROTECTED]> wrote
regarding Re: [pygtk] A question for Python Gurus:
> Hassan Aurag <[EMAIL PROTECTED]> writes:
> > Hi,
> >
> > My question is simple but I can't yet answer it myself. I am still at
> > the point where I use 'Learning Python'.
> >
> > Ok, so I have a terminal and I want to catch the input, and I am not
> > talking about raw_input.
> >
> > I am talking about sys.stdin
> >
> > It seems one can override sys.stdout and sys.stdin to redefine in the
> > first case the print method and the second case the read method.
> >
> > The problem is I don't know how to use them. My goal is to color input
> > depending on text input, eg: in 'def f(x): return x' I want def and
> > return to be colored. I know how to color the string, but I don't know
> > how to make sys.stdin color it! Same thing for sys.stdout where I want
> > it in some cases to format the stuff in some way!
> not quite sure how you want to make stdin eat colors... :))
> what you want is direct terminal control, e.g. with the curses module
> of python, though i don't think this module is properly documented
> (you'd have to use the curses documentation and do an import curses;
> dir(curses); ...).
> If its only for output on a specific terminal, you can directly send
> escape sequences to get colours (to get this for input too you can't
> use local echo on the terminal but have to do the echo yourself).
> IMHO if you are still learning python try to solve some other problems
> first...
> > Any help is appreciated, and please a small example, like
> > def read():
> > return whatever
> >
> > Also, my app is a child process of a zvt (done by fork). Now from
> > whithin the app I want to call a parent's method (in this case, get
> > _size or something to get size of terminal) and since people can
> > resize the terminal I want it to be checked dynamically. How do I do
> > this? Do I get the pid of parent and call its method like:
> > getppid().getsize() or something?
> no. the ppid is just an integer id, and what you need is some form of
> ipc (inter process communication). In this case you get the SIGWINCH
> signal when the size changes, and you can use terminal ioctls. But
> before trying something like this read a good book about Unix.
> ciao
> Andreas
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]