[Python-Dev] Curious comment in some old libraries

Guido van Rossum guido@digicool.com
Fri, 09 Feb 2001 15:08:11 -0500


> Pursuant to a conversation Guido and I had in New York, I have gone
> through and converted the Python library code to use string methods
> wherever possible, removing a whole boatload of "import string"
> statements in the process.

(But note that I didn't ask you to go ahead and do it.  Last time when
I started doing this I got quite a few comments from python-dev
readers who thought it was a bad idea, so I backed off.  It's up to
you to convince them now. :-)

> (This is one of those times when it's a really, *really* good thing that
> most modules have an attached self-test.  I supplied a couple of these
> where they were lacking, and improved several of the existing test jigs.)

Excellent!

> One side-effect of the change is that nothing in the library uses splitfields
> or joinfields anymore.  But in the process I found a curious contradiction:
> 
> stringold.py:# NB: split(s) is NOT the same as splitfields(s, ' ')!
> stringold.py:    (split and splitfields are synonymous)
> stringold.py:splitfields = split
> string.py:# NB: split(s) is NOT the same as splitfields(s, ' ')!
> string.py:    (split and splitfields are synonymous)
> string.py:splitfields = split
> 
> It certainly looks to me as though the "NB" comment is out of date.
> Is there some subtle and wicked reason it has not been removed?

Well, split and splitfields really *are* synonymous, but split(s, ' ')
is *not* the same as split(s).  The latter is the same as split(s,
None) which splits on stretches of arbitrary whitespace and ignores
leading and trailing whitespace.

So the NB is still true...

--Guido van Rossum (home page: http://www.python.org/~guido/)