I would like to get my subclass Sub
class object from my api.py:
import inspect
from tm_base import Base
import tm_child
for k, v in vars(tm_child).iteritems():
if inspect.isclass(v):
if (Base in inspect.getmro(v) and
not inspect.isabstract(v)):
print v
When running the api.py I get both:
<class 'tm_child.Sub'>
<class 'tm_base.Base'>
and I would like <class 'tm_child.Sub'>
only, this is why I am using not inspect.isabstract(v)
. I do not see what is wrong with my code..
Here my other files.
tm_base.py
from abc import ABCMeta
class Base(object):
__metaclass__ = ABCMeta
tm_child.py
from tm_base import Base
class Sub(Base):
pass