[Tutor] length of a string? Advice saught

Alan Gauld alan.gauld at btinternet.com
Thu Jan 28 00:57:45 CET 2010


"Kirk Z Bailey" <kbailey at howlermonkey.net> wrote

>I wrote a program to let me edit web-pages without bothering with ftp; it 
>loads up a simple form with the page guts in it, and saves it through 
>another script.

> truncated it- completely omitted the last 1/4 of the original file, 
> creating big problems. Looking everything over, I can only conclude that 
> somehow python 2.23 (ok, it's an old server; shoot me, I'm poor) has a 
> limit on a simple string variable.

Since you don't give us any clues as to how your program works
I can only guess, but I suspect the problem lies not in the string
variable but in the means of populating it. Did you use read()?
And if so from where?

read() functions usually have an optional buffersize parameter
set to a "reasonable" size. If you try to read more than that it
will be truncated. This is explained in the read() documentation
for files. The urllib module has a similar limitation as indicated
by this quote from the docs:

----------------------
One caveat: the read() method, if the size argument is omitted or negative,
may not read until the end of the data stream; there is no good way to
determine that the entire stream from a socket has been read in the general 
case.
------------------------

I don;t know if you are using either a file read() or urlib.read()
but that may be the cause of the problem?

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 




More information about the Tutor mailing list