[Tutor] Limit on number of characters in a string?

Jeff Shannon jeff at ccvcorp.com
Thu Oct 9 20:41:07 EDT 2003


Jeffery Chin wrote:
> Is there a limit on how many characters can be in a string?  I'm using
> pythonwin with python 2.3 and there seems to be a limit.
> 
> I'm trying to concatenate lines from a file to make one continuous string
> and it won't grow beyond a certain length.
> I think it cuts it off around 3800 characters, but this was not consistent,
> but looking at the screen output, it certainly would not add more to the
> string.

I've used Python to manipulate a file that uses 4K (4096 character) 
long lines, so that's not your problem.

However, *displaying* such long lines can frequently be a significant 
issue.  PythonWin starts to behave rather oddly when dealing with 
lines that are several kB long.  Instead of trying to display the 
entire string, try just displaying its len() before and after the 
concatenation.  This should demonstrate that the string is indeed growing.

Jeff Shannon
Technician/Programmer
Credit International




More information about the Tutor mailing list