简体   繁体   中英

When does Python do automatic type conversion?

When does Python do automatic type conversion?

--

Update:

I asked this after reading this post: In praise of Go or : "Why I moved from Python and C++ to Go" . The one of the points the poster makes is that:

  • It is statically typed, so it is more explicit and the code of a third party is more readable. Also it 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's talking about implicit numeric conversions . Of course, Python has these as 1.0 + 2 will convert 2 to 2.0 and return 3.0 .

It doesn't - it has duck typing instead.

(I may have misunderstood what you meant by automatic type conversion, though, so it would help if you give more detail in your question.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM