When does Python perform automatic type conversion?

When does Python perform automatic type conversion?

-

Update:

I requested this after reading this post: To greet Go or: "Why I switched from Python and C ++ to Go . " One of the points that a poster makes is as follows:

  • It is statically typed, so it is more explicit and third-party code is more readable. It also eliminates the risk of unwanted automatic type conversions (unlike Python).

I had no idea what he meant by "unwanted automatic type conversions." Now, I think, he is talking about implicit numerical conversions . Of course, Python has these values ​​because it 1.0 + 2converts 2to 2.0and returns 3.0.

+3
source share
1 answer

This is not so: instead of duck typing .

(Perhaps I misunderstood what you had in mind when automatically converting types, so this will help if you give more details in your question.)

+1
source

Source: https://habr.com/ru/post/1775356/


All Articles