a splitting headache

Carl Banks pavlovevidence at gmail.com
Thu Oct 22 07:47:24 CEST 2009


On Oct 21, 12:46 pm, David C Ullrich <dullr... at sprynet.com> wrote:
> On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote:
> > On Oct 20, 1:51 pm, David C Ullrich <dullr... at sprynet.com> wrote:
> > I'm not saying either behaviour is wrong, it's just not obvious that the
> > one behaviour doesn't follow from the other and the documentation could
> > be
> > a little clearer on this matter. It might make a bit more sense to
> > actually
> > mention the slpit(sep) behavior that split() doesn't do.
>
> Have you _read_ the docs? They're quite clear on the difference
> between no sep (or sep=None) and sep=something:

Even if the docs do describe the behavior adequately, he has a point
that the documents should emphasize the counterintutive split
personality of the method better.

s.split() and s.split(sep) do different things, and there is no string
sep that can make s.split(sep) behave like s.split().  That's not
unheard of but it does go against our typical expectations.  It would
have been a better library design if s.split() and s.split(sep) were
different methods.

That they are the same method isn't the end of the world but the
documentation really ought to emphasize its dual nature.


Carl Banks



More information about the Python-list mailing list