I'm actually intimidated enough by a few tries I make to say something
on Python-Ideas, that I thought I'd run this by youguys first.

import sys
class ThreadedOut:
        def __init__( self, old ):
                self._old= old
        def write( self, s ):
                self._old.write( s )
sys.stdout= ThreadedOut( sys.stdout )

>>> a
>>> 0
0

Python 3.0a2 WinXP, on the console.  'a' is undeclared but error
message isn't thrown.  With 'sys.stdout= Thr...' commented:

>>> a
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'a' is not defined
>>> 0
0

But the docs say:

stdout and stderr needn't be built-in file objects: any object is
acceptable as long as it has a write() method that takes a string
argument.

What's the catch?
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to