[Python Wpg] Minor headache with substrings

Mike Pfaiffer high.res.mike at gmail.com
Fri Feb 22 18:53:32 EST 2008


	First off this is a precursor to my first adventure with GUI 
programming. I figured I'd write something which works first and then 
add a GUI to it.

	I want to split a rather large string (< 2,000,000 characters) at 
random locations. The resulting substrings get sent out to a file for 
later reassembly. At this point it is only coincidental the substrings 
are sequential to each other. I've been using 
"original_string[start:length]" to copy the data to a second string 
which goes to the output file. I'm able to calculate the start for the 
subsequent substrings correctly. However when putting the substring in a 
second variable I occasionally get a length of 1 (which should never 
occur). Seeing this problem on the screen, I now think I'm missing 
something. I think it could be in one of three areas. Either it's 
something about the nature of strings in Python. Maybe I should be using 
a different procedure to take out substrings. Or there is a problem with 
the size of "start" or "length". So I suppose my question is am I on the 
right track with this?

				Later
				Mike




More information about the Winnipeg mailing list