[Python-Dev] Re: [I18n-sig] Unicode experience
Fri, 7 Jul 2000 17:01:09 -0400
> It's certainly caught errors for me, and especially when
> introducing Perl programmers to Python, where "they expect"
> string+number to convert the string to a number, apparently
> the opposite of the arbitrary choice Paul prefers.
> It's not arbitrary -- the decision is made according to the
> type of the *operator* rather than the type of the operands.
> anything + anything returns a number
> anything . anything returns a string
Of the languages discussed, this is true only in Perl. The other languages
map "+" to the string meaning, so it's arbitrary wrt the universe under
discussion. Toss Icon into the Perl camp on this one, btw.
Within Perl, that "+" means numeric addition and "." string catenation is
also abitrary -- it could just as well have been the other way around. Perl
simply aped Awk's arbitrary <wink> choice for what "+" means.
> So "34"+0 converts to a number and 34."" converts to a string
> (i've seen both idioms fairly often).
Yes, & about as often as you see explicit str() or int() calls in Python.
It's not a question of not needing the functionality, but of how to spell it
> there's really no excuse for not being explicit.
i-think-that's-what-i-said-the-first-time<wink>-ly y'rs - tim