Implicit Conversions

  • Thread starter =?iso-8859-1?B?UmVuZek=?=
  • Start date
?

=?iso-8859-1?B?UmVuZek=?=

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?
Reneé
 
S

Serge Orlov

Mel Wilson said:
Anybody?

Speaking as a Python programmer (not a Python developer),
I would say that Python doesn't generally do implicit
conversions.
To be more specific Python Virtual Machine doesn't do implicit
conversions. However any class including builtin ones can
convert any input argument to any other type. From the
outer point of view (e.g. user of int class) it's implicit conversion,
but from inner point of view (e.g. int class) there is no implicit
conversions of input arguments so the int class has to explicitly
convert them.

-- Serge.
 
J

John Roth

The coercion rules are documented in the Python Reference Manual under
Data Model - Special Method Names - Coercion Rules.

John Roth


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?
Reneé
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,277
Latest member
VytoKetoReview

Latest Threads

Top