[Tutor] Does casting exist in Python?

Edgar Antonio Rodriguez Velazco edgar.antonio.rv at gmail.com
Thu Feb 23 04:02:36 CET 2006


> No, because variables are untyped in Python there is no need for
> casting. In Python values have types, variables are just names. You just
> use the value and if it has the correct type it will work.
>
> There are some functions that transform values from one type to another.
> These are not really casts, they create new values of a different type.
> Some examples are int(), str(), float(). For example:
>
> >>> i=3
> >>> type(i)
> <type 'int'>
> >>> f=float(i)
> >>> f
> 3.0
> >>> type(f)
> <type 'float'>
>
> Kent
I realize now that. Thank you ;-)

PD: I think python is better than I thought before. xD
PD2: Apologize for my English.

--
Edgar A. Rodriguez V.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060223/ae052428/attachment.htm 


More information about the Tutor mailing list