Skip to content

Instantly share code, notes, and snippets.

@mtomwing
Created February 28, 2014 00:48
Show Gist options
  • Save mtomwing/9262932 to your computer and use it in GitHub Desktop.
Save mtomwing/9262932 to your computer and use it in GitHub Desktop.
import abc
class Plugin(object):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def this_method_is_required(self, foo):
pass
class SpecificVideoPlugin(Plugin):
def this_method_is_required(self, foo):
return foo[::-1]
# Trying to instantiate the interface directly will result in an exception
plugin = Plugin()
# However instantiating the subclass will work because it overrode the abstract method
plugin = SpecificVideoPlugin()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment