Comment on draft PEP for deprecating six builtins

John Roth johnroth at ameritech.net
Tue Apr 30 14:36:56 EDT 2002


"Duncan Booth" <duncan at NOSPAMrcp.co.uk> wrote in message
news:Xns9200AC87B7A86duncanrcpcouk at 127.0.0.1...
> Roman Neuhauser <neuhauser at mail.cz> wrote in
> news:mailman.1020172854.26653.python-list at python.org:
>
> >> I prefer writing
> >>    str.join(' ', aList)
> >> rather than
> >>    ' '.join(aList)
> >>
> >> When the string is a literal I find the former reads much better.
YMMV
> >
> >     IMO that's because join being a string method is just awkward.
How
> >     does this read:
> >     aList.join(' ')
> >     After all, you tell the list to give you it's concatenation,
using
> >     the argument as the glue.
>
> That doesn't work if you want to join a tuple, or an iterator or any
other
> sequence. Dont forget you can even join a string:
> >>> print str.join(',', 'abc')
> a,b,c

Doesn't matter. What we need is <sequence>.join(<string>)
where the resulting string is the result of applying str() to each
of the members of the sequence, with the <string> between
each pair of members. In other words, .join() is a member
function of all objects that have a sequence interface.

John Roth






More information about the Python-list mailing list