[Python-bugs-list] [ python-Bugs-671447 ] StringIO doc doesn't say it's sometimes read-only

SourceForge.net noreply@sourceforge.net
Tue, 21 Jan 2003 13:17:11 -0800


Bugs item #671447, was opened at 2003-01-21 00:58
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=671447&group_id=5470

Category: Documentation
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Mike Orr (hierro)
Assigned to: Nobody/Anonymous (nobody)
Summary: StringIO doc doesn't say it's sometimes read-only

Initial Comment:
When StringIO is instantiated with an intial string:
StringIO("Hello, world!")
it's read-only; the write methods don't exist.  The
Python Library Reference should mention this.

If you instantiate StringIO without an initial string:
StringIO()
you get both read and write methods.

----------------------------------------------------------------------

Comment By: Christos Georgiou (tzot)
Date: 2003-01-21 23:17

Message:
Logged In: YES 
user_id=539787

I find your suggestion informative, appropriate and nice :)

----------------------------------------------------------------------

Comment By: Mike Orr (hierro)
Date: 2003-01-21 23:09

Message:
Logged In: YES 
user_id=239757

Yes, it's only cStringIO that does it.

However, the statenent about the type does not say anything
about which methods are available.  Many readers would
think, "I never have to compare the type to anything; this
doesn't apply to me."  How about a statement:

If you instantiate cStringIO.StringIO() without an argument,
the string is read-write.  But if you instantiate it with a
string argument: cStringIO.StringIO("abc"), it's read-only
and the write methods do not exist.  This applies only to
cStringIO; the corresponding objects in the StringIO module
are read-write in both cases.  [Then the paragraph about
InputType and OutputType.]

----------------------------------------------------------------------

Comment By: Christos Georgiou (tzot)
Date: 2003-01-21 22:24

Message:
Logged In: YES 
user_id=539787

Did you import StringIO, or cStringIO as StringIO ?

This behaviour occurs only in cStringIO... if you do

m= cStringIO.StringIO("hello there")
n= cStringIO.StringIO()

you see that type(m) is cStringIO.StringI and n is 
cStringIO.StringO.

This is documented in the cStringIO module documentation.

 

----------------------------------------------------------------------

Comment By: Christos Georgiou (tzot)
Date: 2003-01-21 22:24

Message:
Logged In: YES 
user_id=539787

Did you import StringIO, or cStringIO as StringIO ?

This behaviour occurs only in cStringIO... if you do

m= cStringIO.StringIO("hello there")
n= cStringIO.StringIO()

you see that type(m) is cStringIO.StringI and n is 
cStringIO.StringO.

This is documented in the cStringIO module documentation.

 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=671447&group_id=5470