I want to extract the python class name while using abstract classes with abc
library. I unfortunately instead receive the class name ABCMeta
.
import abc
class A(abc.ABC)
pass
class B(A)
pass
print(A.__class__.__name__) # output: 'ABCMeta'
print(B.__class__.__name__) # output: 'ABCMeta'
print(str(A)) # output: "<class '__main__.A'>"
print(str(B)) # output: "<class '__main__.B'>"
I expect that I should receive the output as below
print(A.__class__.__name__) # output: 'A'
print(B.__class__.__name__) # output: 'B'
The str(A)
and str(B)
seems to print the class name so I assume the class name can be extracted from somewhere. But nonetheless, I am not interested to use str
to parse and get the class name.