For review: PEP 308 - If-then-else expression
Andrew Dalke
adalke at mindspring.com
Tue Feb 11 14:08:41 EST 2003
Christian Tismer
> Andrew Koenig:
> > If I were trying to make code easy to understand for inexperienced
> > programmers, I would write str.join(',', lines) instead of
> > ','.join(lines).
>
> Great idea, IMHO!
I thought it was kinda neat as well, until I realized
str.join(sep, ["A", "B"])
requires that sep be a byte string.
>>> str.join(u",", ["A", "B"])
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: descriptor 'join' requires a 'str' object but received a
'unicode'
>>>
Doing
sep.join(["A", "B"])
is better because it doesn't enforce the extra type checking.
Andrew
dalke at dalkescientific.com
More information about the Python-list
mailing list