cStringIO.StringIO has no write method?

Alexis Roda arv.nntp at gmail.com
Tue Jul 25 15:34:39 EDT 2006


En/na Laszlo Nagy ha escrit:
> 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)

from cStringIO documentation:


     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.



HTH



More information about the Python-list mailing list