hasattr documentation says that it takes an object and an attribute name and lets you know if that attribute exists on that object.
I have discovered that it seems to work on class names too (i.e. not an instance object).
Something like:
class A:
def Attr1(self):
pass
> hasattr(A, 'Attr1')
True
>
I would like to use this to make some test code easier to write, but don't want to be bitten later in case this is a side effect of the implementation and not really intended.
Please don't ask to see the test code to see if I can do something else, as that is not really the question.
Is there any official python stance on this? I presume the object referred to, in the documentation is talking about an instance object.
I tried googling (and looking at some questions in StackOverflow), but didn't seem to find anything.