computing with characters
George Sakkis
george.sakkis at gmail.com
Wed Apr 30 20:00:01 EDT 2008
On Apr 30, 3:53 pm, Mel <mwil... at the-wire.com> wrote:
> George Sakkis wrote:
> > def join(iterable, sep=' ', encode=str):
> > return sep.join(encode(x) for x in iterable)
>
> Actually
>
> return encode(sep).join(encode(x) for x in iterable)
>
> lest you get TypeErrors for non-string separators.
Well separator is almost always a string literal or at least known to
be a string, so that TypeError has never occured to me.
George
More information about the Python-list
mailing list