cStringIO
index
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/cStringIO.so
Module Docs

A simple fast partial StringIO replacement.
 
This module provides a simple useful replacement for
the StringIO module that is written in C.  It does not provide the
full generality of StringIO, but it provides enough for most
applications and is especially useful in conjunction with the
pickle module.
 
Usage:
 
  from cStringIO import StringIO
 
  an_output_stream=StringIO()
  an_output_stream.write(some_stuff)
  ...
  value=an_output_stream.getvalue()
 
  an_input_stream=StringIO(a_string)
  spam=an_input_stream.readline()
  spam=an_input_stream.read(5)
  an_input_stream.seek(0)           # OK, start over
  spam=an_input_stream.read()       # and read it all
  
If someone else wants to provide a more complete implementation,
go for it. :-)  
 
cStringIO.c,v 1.29 1999/06/15 14:10:27 jim Exp

 
Classes
       
__builtin__.object
StringI
StringO

 
InputType = class StringI(__builtin__.object)
    Simple type for treating strings as input file streams
 
  Methods defined here:
__iter__(...)
x.__iter__() <==> iter(x)
close(...)
close(): explicitly release resources held.
flush(...)
flush(): does nothing.
getvalue(...)
getvalue([use_pos]) -- Get the string value.
If use_pos is specified and is a true value, then the string returned
will include only the text up to the current file position.
isatty(...)
isatty(): always returns 0
next(...)
x.next() -> the next value, or raise StopIteration
read(...)
read([s]) -- Read s characters, or the rest of the string
readline(...)
readline() -- Read one line
readlines(...)
readlines() -- Read all lines
reset(...)
reset() -- Reset the file position to the beginning
seek(...)
seek(position)       -- set the current position
seek(position, mode) -- mode 0: absolute; 1: relative; 2: relative to EOF
tell(...)
tell() -- get the current position.
truncate(...)
truncate(): truncate the file at the current position.

Data descriptors defined here:
closed
True if the file is closed

 
OutputType = class StringO(__builtin__.object)
    Simple type for output to strings.
 
  Methods defined here:
__iter__(...)
x.__iter__() <==> iter(x)
close(...)
close(): explicitly release resources held.
flush(...)
flush(): does nothing.
getvalue(...)
getvalue([use_pos]) -- Get the string value.
If use_pos is specified and is a true value, then the string returned
will include only the text up to the current file position.
isatty(...)
isatty(): always returns 0
next(...)
x.next() -> the next value, or raise StopIteration
read(...)
read([s]) -- Read s characters, or the rest of the string
readline(...)
readline() -- Read one line
readlines(...)
readlines() -- Read all lines
reset(...)
reset() -- Reset the file position to the beginning
seek(...)
seek(position)       -- set the current position
seek(position, mode) -- mode 0: absolute; 1: relative; 2: relative to EOF
tell(...)
tell() -- get the current position.
truncate(...)
truncate(): truncate the file at the current position.
write(...)
write(s) -- Write a string to the file
 
Note (hack:) writing None resets the buffer
writelines(...)
writelines(sequence_of_strings) -> None.  Write the strings to the file.
 
Note that newlines are not added.  The sequence can be any iterable object
producing strings. This is equivalent to calling write() for each string.

Data descriptors defined here:
closed
True if the file is closed
softspace
flag indicating that a space needs to be printed; used by print

 
Functions
       
StringIO(...)
StringIO([s]) -- Return a StringIO-like stream for reading or writing

 
Data
        cStringIO_CAPI = <capsule object "cStringIO.cStringIO_CAPI">