[Python-Dev] Re: [I18n-sig] Unicode experience

Ka-Ping Yee pingster@ilm.com
Fri, 7 Jul 2000 13:50:32 -0700 (PDT)


On Fri, 7 Jul 2000, Tim Peters wrote:
> > Are you sure?  This is the kind of error where you immediately see
> > what's wrong and move on to the next bug.
>
> 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

So "34"+0 converts to a number and 34."" converts to a string
(i've seen both idioms fairly often).

Anyway, i still agree that it's best to avoid automatic coercion
between numbers and strings -- since it's now very easy to say
int("3") as opposed to import string; string.atoi("3"), there's
really no excuse for not being explicit.


-- ?!ng

"Things are more like they are now than they ever were before."
    -- Dwight D. Eisenhower