splitting using '\' as a delimiter

Tim Roberts timr at probo.com
Mon Dec 3 01:56:44 EST 2001


"Peoter Veliki" <peoter_veliki at hotmail.com> wrote:
>
>So the string.split and the re.split swap the order of the arguments??!!
>What was the logic behind this decision?

Accident, I suspect.  The string is first in string.split because the
delimiter string is optional.  If the delimiter were first, it would be
required.

You could also argue that the two have different focus.  In string.split,
the focus is on the string.  The string is being told to split itself,
based on the delimiters.  In re.split, the focus is on the regular
expression.  The re is being told to take a specific action, in this case
to split up a string.

This little inconsistency remains even with the new syntax:

   string_to_be_split.split( delimiters )
   regular_expression.split( string_to_be_split )
--
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list