Equivalent to c++ typeof(x)
Hans Nowak
wurmy at earthlink.net
Wed Jan 9 11:37:23 EST 2002
Andrew Wilkinson wrote:
>
> Hi,
>
> Is there any equivalent in Python to the C++ construct
>
> typeof(<instance variable>) == typeof(<class>)
>
> The Python type(<variable>) returns 'instance' for any class, however I
> need to know the extact type of class. So for example...
>
> class a:
> pass
>
> class b:
> pass
>
> x = a()
> y = b()
>
> type(x) == type(y) # I'd like this line to return false but it returns
> true!
Well, you can use the __class__ attribute:
>>> x.__class__ is y.__class__
0
--Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA==')
# decode for email address ;-)
Site:: http://www.awaretek.com/nowak/
More information about the Python-list
mailing list