On 2011-12-10 20:22, Walter Prins wrote:
Is the example wrong, or is this something to do with how Windows
handles stdout that is causing this not to work as designed? I am
using Python 3.2 on Windows Vista Home Premium.
It seems the example may be wrong -- the __exit__ method, as stated
by the error, is being given 4 parameters whereas the one defined in
the code only expects one. I've looked an this is correct on Python
3.2 that I have on Windows as well. Perhaps the implementation of
__exit__ has been changed somewhere and had the paramters added and
the book is just out of date? In any case, changing the def
__exit__ line to:
def __exit__(self, type, value, traceback):
... will fix the problem.
Perhaps a typo in the book, because the online-version
(http://www.diveintopython3.net/examples/stdout.py) works:
def __exit__(self, *args):
sys.stdout = self.out_old
Bye, Andreas
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor