Once a class is constructed (i.e. defined, not instantiated), I can access its dunder attributes.
>>> class Foo:
... 'This is a class.'
>>> Foo.__doc__
'This is a class.'
Is there any way I can access __doc__
while the class is being defined?
class Foo:
'This is a class.'
a = Foo.__doc__ # does not work because Foo is not defined yet
Or can this not be done because __doc__
is only assigned by the meta class after the class body has been executed? Is there an alias for it then? How about other dunder attributes/methods?