[Python-Dev] partition() (was: Remove str.find in 3.0?)

Phillip J. Eby pje at telecommunity.com
Tue Aug 30 17:22:25 CEST 2005


At 10:01 AM 8/30/2005 +0200, Fredrik Lundh wrote:
>Phillip J. Eby wrote:
>
> >>   Check out (and Pythonify) the ANSI M[UMPS] $PIECE(). See:
> >>   http://www.jacquardsystems.com/Examples/function/piece.htm
> >
> > As far as I can see, either you misunderstand what partition() does, or
> > I'm
> > completely misunderstanding what $PIECE does.  As far as I can tell,
> > $PIECE
> > and partition() have absolutely nothing in common except that they take
> > strings as arguments.  :)
>
>both split on a given token.  partition splits once, and returns all three
>parts, while piece returns the part you ask for

No, because looking at that URL, there is no piece that is the token split 
on.  partition() always returns 3 parts for 1 occurrence of the token, 
whereas $PIECE only has 2.


>(the 3-argument form is
>similar to x.split(s)[i])

Which is quite thoroughly unlike partition.



More information about the Python-Dev mailing list