On Jul 28, 7:32 am, Steven D'Aprano <st...@remove-this-
cybersource.com.au> wrote:
> On Wed, 28 Jul 2010 09:35:52 -0400, wheres pythonmonks wrote:
> > Thanks ... I thought int was a type-cast (like in C++) so I assumed I
> > couldn't reference it.
>
> Python doesn't have type-casts in the sense of "tell the compiler to
> treat object of type A as type B instead". The closest Python has to that
> is that if you have an instance of class A, you can do this:
>
> a = A()  # make an instance of class A
> a.__class__ = B  # tell it that it's now class B
>
> and hope that it won't explode when you try to use it :/

Type casts in C and non-pathlogical C++ don't modify the object they
are casting.

int (and str, float, etc.) is the closest thing to a type cast in
Python.


Carl Banks
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to