No 1.6! (was Re: A REALLY COOL PYTHON FEATURE:)

Samuel A. Falvo II kc5tja at garnet.armored.net
Wed May 24 20:31:00 CEST 2000


At the risk of sounding huffy, I'd like to voice my (particularly strong)
opinions on this particular subject matter.

In article <39256A08.C77804B0 at dial.pipex.com>, Kevin Digweed wrote:
>    result = ' '.glue(['hello', 'world'])
>    result = ' '.bind(['hello', 'world'])

This is utterly unacceptable and outright appalling syntax.  I'm sorry.  The
above code just goes to show you precisely what featuritis can bring, and
why it must be tightly controlled.  This type of syntactic nightmare serves
only to confound new-comers to the language.  I'm actively trying to teach
several people how to write object oriented code (one of whom's last
programming venture was with Fortran back in the 70s), and this would blow
their minds to pieces.

It doesn't make any amount of sense to say, "Space, join/glue/bind these
strings together."  Something like this:

	result = 'hello'.append( 'world' )

makes sense to newcomers, because we're doing something tangible with the
'hello' string.  The above code not only won't be obvious, but it also makes
the source code more difficult to read.  When I saw that code for the first
time, I honestly thought it was Perl.

But if there are a number of list elements involved, then a factory function
should be employed, NOT a command on a single character.  It doesn't make
any amount of sense to say, "Space, bind these list elements," because
you're telling a single space to fill in potentially many spots (that is,
you're telling *an* object to split and become many).  Instead, what we want
is to create a *new* string (not boss an old one around) that contains
delimited fields.  This is what's so nice about result = string.join(
someList, withThisCharacter ).  The operation being performed is blatantly
obvious, even to the newcomer.

Unless, of course, you like Javascript-isms strewn about your Python code.
:-)

-- 
KC5TJA/6, DM13, QRP-L #1447
Samuel A. Falvo II
Oceanside, CA



More information about the Python-list mailing list