Minor inconsistency between cStringIO and (StringIO or normal fil es)...

Tres Seaver tseaver at starbase.neosoft.com
Fri Jan 21 22:07:03 EST 2000


In article <CC59868A0A76D311B1F50090277B321C1F3092 at VRTMAIL>,
Mike Fletcher  <mfletch at tpresence.com> wrote:
>Following demonstrates the inconsistency, essentially, a seek to maxint
>raises a memory error on a cStringIO object, whereas the StringIO and file
>objects just move to the end of the file for further actions (which is very
>handy).  Is there a better way to spell "move to end of file" (keeping in
>mind that this is for a class doing effectively random access in the
>buffer)?
>
>Cheers,
>Mike
>
>PythonWin 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
>Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>Portions Copyright 1994-1999 Mark Hammond (MHammond at simporkippinet.com.au)
>>>> import cStringIO, sys
>>>> d = cStringIO.StringIO()
>>>> d.seek(sys.maxint)
>Traceback (innermost last):
>  File "<interactive input>", line 1, in ?
>MemoryError: 
>>>> d = open( 'z:\\temp\\test.wrl','r')
>>>> d.seek(sys.maxint)


d.seek( 0, 2 ) # optional second argument gives POV
               # 0 = from start (default)
               # 1 = from current
               # 2 = from end, backward

Best,

Tres.
-- 
---------------------------------------------------------------
Tres Seaver           tseaver at palladion.com       713-523-6582
Palladion Software    http://www.palladion.com



More information about the Python-list mailing list