> Steven Bethard <[EMAIL PROTECTED]> wrote: > > py> class A: > > ... pass > > ... > > py> class B: > > ... pass > > ... > > py> a = A() > > py> a.__class__ == A > > True > > py> a.__class__ == B > > False
"Just" <[EMAIL PROTECTED]> wrote > Uh, isinstance(a, A) works for both new-style and old-style classes. > Heck, isinstance() even works in Python 1.5.2... Oh, there! Not that there is anything wrong with new classes, but that is just the sort of thing that I expected to find. No, neither of these is bad at all. I was looking for something like the obj.__class__ attribute, but I couldn't see it under dir(obj). So, why is _class__ magically tucked away where you can't see it? That doesn't seem very "Pythonic". I also looked in my two python books for instance(), or instanceof() functions - wasn't seeing anything. Actually, now that I check the indices of "Learning Python" 1E & "Programming Python" 2E, I don't see isinstance() either. How unfortunate. :( As an aside, I notice a lot of other people's interpreters actually print 'True' or 'False' where my system prints 0 or 1. Is that a configuration that can easily set somewhere? Thanks for your help! -ej -- http://mail.python.org/mailman/listinfo/python-list