[Zope] Best Zope way to split a textfield on 2000 char increments

Bill Anderson bill@noreboots.com
Fri, 15 Dec 2000 18:01:18 -0700


Jerome Alet wrote:
> 
> On Fri, 15 Dec 2000, Steve Drees wrote:
> 
> > somestring[:1999] is the first 2000 characters of somestring.
> 
> Not to be a poseur but:

me either ;^)=

 
> somestring[:1999] is the first 1999 characters of somestring, because
> in Python indices begin at 0, e.g.:

Actually, it is because the number 1999 refers to the the spot
*inbetween* 1998 and 1999. Basically, in a list of '0,1,2,3', [0] is the
first 'comma', and [1] the second, and so on. Counting that way shows
that you never include the 1999 (or the three in your example. It isn't
that indices start at zero, it is due to the counting being done on the
seperator, not the item in the list.

> a="0123"
> print a[:3] gives "012" which are the first 3 characters from a.

Right, because 'a' is being treated as [0,1,2,3], and you are saying
"give me everything up to the third comma". :)

yes-I-am-nitpicking-ly y'rs Bill Anderson