[Tutor] A Million Sevens
pyro9219 at gmail.com
Sun Nov 19 00:44:00 CET 2006
That must be part of Pythons shiny ability of dynamic data types? Must be a
messy operation to change data-types like that.. I think I'll just do my
best to work with the right data-types the whole time ;D
On 11/18/06, Alan Gauld <alan.gauld at btinternet.com> wrote:
> "Chris Hengge" <pyro9219 at gmail.com> wrote
> > Not that it changes your reply, but just for my own sanity:
> > int('7' * 10 ** 6) <- does this not just type-cast a char into an
> > int?
> Chris, I suspect you may come from a C background?
> Type *conversion* in Python is very differentb from
> type *casting* in C.
> type casting says take the binary data stored at x and treat
> it as a different type, thats pretty well instantaneous.
> typecasting (int)'77' in C will not give you the number
> 77(decimal) but will give you the hex value 0x3737
> which is entirely different (actually 14135!).
> Now typecasting in C++ is somewhat different, especially
> if you use dynamic casts and that can involve converting
> the type rather than just treating the existing data differently...
> Because of this confusion over the word cast I prefer
> to refer to Python as doing type conversions.
> Type conversion says take the data entity in variable x
> and change its internal structure to the representation
> of a new type. Thats a much more complex operation.
> Alan Gauld
> Author of the Learn to Program web site
> Tutor maillist - Tutor at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor