For review: PEP 308 - If-then-else expression

Erik Max Francis max at alcyone.com
Sun Feb 9 18:32:56 EST 2003


Roy Smith wrote:

> I don't follow.  What's an "instance method" as opposed to a "class
> method"? [in the context of the string join method]

I presume he means something like (with S as the sequence, D as the
string delimiter)

	str.join(S, D)

instead of

	D.join(S)

Problem is, type unification came long after string methods, so that
wouldn't have been feasible.

If you really find the join method offensive, you can always just use
the string module function.

> What I was trying to say is that I think instead of:
> 
> >>> breakfastItems = ['spam', 'eggs', 'spam', 'spam', 'spam', 'and
> spam']
> >>> ', '.join (breakfastItems)
> 'spam, eggs, spam, spam, spam, and spam'
> 
> it should have been:
> breakfastItems.join (', ')

The problem is that by logical extension now _every_ sequence (including
user-defined ones) has to implement a join method, which turns things on
their head since joining is a string-specific operation, not a
sequence-specific operation.  It should be on the onus of strings to
implement it, not every other sequence in existence.

To me, having the join string method seemed the only sensible way to do
it, so I consider it highly Pythonic.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ He who knows how to be poor knows everything.
\__/ Jules Michelet
    Rules for Buh / http://www.alcyone.com/max/projects/cards/buh.html
 The official rules to the betting card game, Buh.




More information about the Python-list mailing list