Suppose I need to implement an abstract Python interface which then will have many derived classes (each named equally but written in different modules), and in base class I heed to have a common method which will use a particular imported derived class' static method.
So my toy modules look like this:
abstract_class.py
from abc import ABCMeta, abstractmethod
from derived_class import Derived
class Abstract:
__metaclass__ = ABCMeta
@abstractmethod
def foo(self):
pass
def bar(self):
Derived.foo()
derived_class.py
from abstract_class import Abstract
class Derived(Abstract):
@staticmethod
def foo():
print 'Good news everyone!'
if __name__ == '__main__':
derived_object = Derived()
derived_object.bar()
Then of course when I'm trying to run derived_class.py
, I get the Abstract name import error.
How do I properly organize this?