[Python-Dev] Alternative name for str.partition()

Christian Stork python-dev-list at cstork.org
Wed Sep 21 20:56:01 CEST 2005

I know I'm coming too late to this discussion, but just for completeness
sake let me mention that the OCaml standard List module uses 'partition'
already in the sense that most mathematically educated people would
understand it:

    val partition : ('a -> bool) -> 'a list -> 'a list * 'a list

    partition p l returns a pair of lists (l1, l2), where l1 is the list
    of all the elements of l that satisfy the predicate p, and l2 is the
    list of all the elements of l that do not satisfy p. The order of
    the elements in the input list is preserved.

Haskell's Data.List.partion is defined the same way.

So this seems to be generally agreed upon, at least for functional
programming languages.  This is why I have to agree with Greg:

On Tue, Aug 30, 2005 at 12:49:26PM +1200, Greg Ewing wrote:
> A more descriptive name than 'partition' would be 'split_at'.

'split_at' is really what's happening.  (I came up with it independently
of Greg, if that is any evidence).

Chris Stork   <>  Support eff.org!  <>   http://www.ics.uci.edu/~cstork/
OpenPGP fingerprint:  B08B 602C C806 C492 D069  021E 41F3 8C8D 50F9 CA2F

More information about the Python-Dev mailing list