Using the 'with' statement with cStringIO objects
George Boutsioukis
gboutsioukis at gmail.com
Sat Sep 27 09:31:40 EDT 2008
> So, I'm guessing you can't use the 'with' statement with cStringIO
> objects? Is this a bug, or do I need to use the 'with' statement
> differently to get this to work?
>
> Thanks,
> peppergrower
Neither, just not implemented. Only classes with __enter__ and __exit__
methods(ie context manager types) can be used in with statements. And,
correct me if I'm wrong, I think it's pointless for a StringIO object to
have those.
More information about the Python-list
mailing list