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

Christian Tismer tismer at tismer.com
Tue Feb 11 23:42:27 CET 2003


Andrew Dalke wrote:
> 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'

The thing is symmetric:
 >>> unicode.join(u" ", ("a","b"))
u'a b'

> Doing
>   sep.join(["A", "B"])
> 
> is better because it doesn't enforce the extra type checking.

It is all, somehow,consequent.
But I guess, the behavior is by chance and not intended.
Unless the class method notation is an artifact,
I think something should be done about it.
Something like a super-string class, which is as
dynamic as the "".join implementation.
ALternatively, it would need to be considered to
revert here and make the class method calling unavailable.

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer at tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  pager +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/







More information about the Python-list mailing list