Skip to content

Instantly share code, notes, and snippets.

@sapamja
Created August 6, 2014 18:21
Show Gist options
  • Save sapamja/6ed0d09d32396c6f43b9 to your computer and use it in GitHub Desktop.
Save sapamja/6ed0d09d32396c6f43b9 to your computer and use it in GitHub Desktop.
abc.py
import abc
class PluginBase(object):
__metaclass__ = abc.ABCMeta
def __init__(self):
self.base = 'base_info'
@abc.abstractmethod
def load(self, input):
"""Retrieve data from the input source and return an object."""
return
@abc.abstractmethod
def save(self, output, data):
"""Save the data object to the output."""
return
class SubclassImplementation(PluginBase):
def __init__(self):
super(SubclassImplementation, self).__init__()
self.base = 'james'
def load(self, input):
print self.base
return True
def asave(self, output, data):
return True
if __name__ == '__main__':
print 'Subclass:', issubclass(SubclassImplementation, PluginBase)
print 'Instance:', isinstance(SubclassImplementation(), PluginBase)
obj = SubclassImplementation()
obj.load('input')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment