Coding standard: Prefixing variables to indicate datatype

Erik Max Francis max at alcyone.com
Mon Jan 20 03:54:47 EST 2003


Martin Maney wrote:

> Jp Calderone <exarkun at intarweb.us> wrote:
>
> > ("a", "b", "c").join(" ") might make sense, but it would also
> > involve
> > writing a pile more code, and reducing the usefulness of the
> > operation.
> 
> How does that reduce the usefulness?  Seems to me that it would allow
> the restoration of the small conveninence of having a default
> separator, as string.join() did.

Setting aside for the moment this wasn't what the original poster was
talking about, the problem with a join method in every sequence is just
that:  It would have to be in _every_ sequence.  Not just lists, tuples,
(even strings) but user defined types as well.  This complicates the
"sequence" interface, which is at its core very simple:  it implements
the __getitem__ method, returning objects when passed sequential
integers starting from 0, and then raises an IndexError when it's done. 
This interface can be optimized by implementing more methods (say,
__len__), but it's not necessary.

Taking this approach to its logical conclusion, you rapidly get a case
of kitchensinkitis where _every_ sequence has to implement a huge
plethora of methods, or nothing's guaranteed to work.  That's the wrong
way around.

Besides, if you don't like the syntax of JOINER.join(SEQUENCE), you can
always just use the string.join(SEQUENCE, JOINER) function.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ In the little things / And the joy they bring
\__/ India Arie
    Bosskey.net / http://www.bosskey.net/
 A personal guide to online multiplayer first person shooters.




More information about the Python-list mailing list