Implicit Conversions

Mel Wilson mwilson at the-wire.com
Sat Dec 13 12:28:36 EST 2003


In article <mailman.112.1071251837.9307.python-list at python.org>,
"=?iso-8859-1?B?UmVuZek=?=" <rlogan at hmc.edu> wrote:
>I wanted to know the order of implicit conversions and which sort of =
>values
>allow them. From searching around in books and the archive of this =
>mailing
>list, it seems to be that only numbers are implicitly converted within =
>each
>other and bools can be implicitly converted to ints? However, I'm unable =
>to
>find any other implicit conversions and the order of the implicit
>conversions (something like int->float->long). Any help would be greatly
>apprectiated. Also, I'm not on the mailing list so can everyone please =
>cc me
>in the replies?

Anybody?

   Speaking as a Python programmer (not a Python developer),
I would say that Python doesn't generally do implicit
conversions.  The programmer keeps track of the types of the
operands passed to operators and functions, and the
operators and functions do what they can with what they get.

   You have it right that the arithemetic operators work so
as not to lose "comprehensivity":  an operation on a complex
yields a complex OR an operation on a float yields a float,
OR an operation on a long yields a long OR the operation
yields an int.  (Those are Python short-circuiting OR's
there.)

        Regards.        Mel.




More information about the Python-list mailing list