Why can't I access the instance.__class__ attribute in Python?
Posted
by froadie
on Stack Overflow
See other posts from Stack Overflow
or by froadie
Published on 2010-05-14T15:54:06Z
Indexed on
2010/05/14
16:04 UTC
Read the original article
Hit count: 233
I'm new to Python, and I know I must be missing something pretty simple, but why doesn't this very, very simple code work?
class myClass:
pass
testObject = myClass
print testObject.__class__
I get the following error:
AttributeError: class myClass has no attribute '__class__'
Doesn't every object in Python have a __class__
attribute?
© Stack Overflow or respective owner