string.upto() and string.from()

Duncan Booth duncan.booth at invalid.invalid
Wed Mar 22 16:19:29 CET 2006

ikshefem at wrote:

> I often need to re-code for myself a small code snippet to define
> string.upto() and string.from(), which are used like :

> Nothing very complicated to make with find and rfind, but wouldn't this
> be handy to have it ready in the common string method ?

Something similar to this was discussed at length on the development list 
last year. I don't think the discussion reached any concrete decision, but 
the proposal was to add partition and rpartition methods to strings:

As described by Time Delaney:

    partition() splits a string into 3 parts - the bit before the
    first occurrance of the separator, the separator, and the bit
    after the separator. If the separator isn't in the string at
    all then the entire string is returned as "the bit before" and
    the returned separator and bit after are empty strings.


More information about the Python-list mailing list