computing with characters

Mel mwilson at the-wire.com
Wed Apr 30 15:53:16 EDT 2008


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.

        Mel.




More information about the Python-list mailing list