Why doesn't cStringIO.StringIO (<string>) have write methods?

Fredrik Lundh effbot at telia.com
Wed Feb 9 03:27:59 EST 2000


Alex <alex at somewhere.round.here> wrote:
> Hi.  I noticed that when cStringIO.StringIO is instantiated with a
> string, it doesn't have write methods, but when it's instantiated with
> no arguments, it does.  I was curious as to why this is.

two different types:

>>> from cStringIO import StringIO
>>> s = 'TCACCACCACCACCACCATCATCACCACCACCACCATCATCATC'
>>> t = StringIO(s)
>>> t
<StringI object at 796c90>
>>> t = StringIO()
>>> t
<StringO object at 796cf0>

(StringIO is a factory function, not a class)

</F>

<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->





More information about the Python-list mailing list