Laszlo Nagy wrote: > This program: > > import sys > import traceback > import cStringIO > > a = 1.0 > b = 0.0 > try: > c=a/b > except: > f = cStringIO.StringIO('') > ei = sys.exc_info() > traceback.print_exception(ei[0],ei[1],ei[2],file=f) > > raises this exception: > > Traceback (most recent call last): > File "C:/Documents and Settings/gandalf/test.py", line 12, in ? > traceback.print_exception(ei[0],ei[1],ei[2],file=f) > File "C:\Python24\Lib\traceback.py", line 124, in print_exception > _print(file, 'Traceback (most recent call last):') > File "C:\Python24\Lib\traceback.py", line 13, in _print > file.write(str+terminator) > AttributeError: 'cStringIO.StringI' object has no attribute 'write' > > What is 'cStringIO.StringI' anyway? Shouldn't it be 'cStringIO.StringIO'?
See http://docs.python.org/lib/module-cStringIO.html: """ Another difference from the StringIO module is that calling StringIO() with a string parameter creates a read-only object. Unlike an object created without a string parameter, it does not have write methods. These objects are not generally visible. They turn up in tracebacks as StringI and StringO. """ Peter -- http://mail.python.org/mailman/listinfo/python-list