Find class of an instance?

Hugo python at hugo.doemaarwat.nl
Wed Aug 6 10:44:39 EDT 2008


Neal Becker schreef:
> Sounds simple, but how, given an instance, do I find the class?

I always do that with .__class__, not sure whether it is the best way:

 >>> class A:
...  pass
...
 >>> a = A()
 >>> a.__class__
<class __main__.A at 0xb7f01fbc>
 >>> a.__class__ == A
True



More information about the Python-list mailing list