Do I need to convert string to integer in python?

Heiko Wundram modelnine at bit-bukket.org
Sun Feb 26 15:10:22 EST 2006


Allerdyce.John at gmail.com wrote:
> Do I need to convert string to integer in python? or it will do it for
> me (since dynamic type)?

Yes. Dynamic typing doesn't say anything about a string and a number being
"equal," as they are (e.g.) in Perl, it just says that you don't have to
care what type of object a name is bound to. What you are thinking of is
called weak typing (auto-coercion between strings and numbers and such).

You'd have to do something like:
x = int(x)/10

--- Heiko.



More information about the Python-list mailing list