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

Alexander Schmolck a.schmolck at gmx.net
Sun Feb 9 18:26:13 EST 2003


Roy Smith <roy at panix.com> writes:

> I wrote:
> >> I'm with Aahz.  I think it's pretty silly.  Join() should have been a 
> >> method of lists (and maybe tuples?), not of strings.
> 
> aahz at pythoncraft.com (Aahz) wrote:
> > Well, no, that doesn't work, either.  join() should have been a class
> > method rather than an instance method, is what it is.
> 
> I don't follow.  What's an "instance method" as opposed to a "class 
> method"?  What I was trying to say is that I think instead of:

A class method doesn't have an instance ('self') as the first argument but a
class ('cls' or whatever) -- the class of the instance the method belongs to
(see `classmethod`).

> 
> >>> breakfastItems = ['spam', 'eggs', 'spam', 'spam', 'spam', 'and spam']
> >>> ', '.join (breakfastItems)
> 'spam, eggs, spam, spam, spam, and spam'
> 
> it should have been:
> breakfastItems.join (', ')

Says you. How'd you do this: ",".join(iter/seq/tuple/etc. -- anything that's
'__iter__'able')?

I think that would only make sense if there were some `iterable` type (with
that method) all the sequence types derived from, but python doesn't work like
that.


alex




More information about the Python-list mailing list