Skip to content

Instantly share code, notes, and snippets.

@cdunklau
Last active August 29, 2015 14:02
Show Gist options
  • Save cdunklau/5cd2286e3fe2aed87405 to your computer and use it in GitHub Desktop.
Save cdunklau/5cd2286e3fe2aed87405 to your computer and use it in GitHub Desktop.
Registry pattern - avoid magic, be (reasonably) explicit
registry = {}
def registered(cls):
registry[cls.__name__] = cls
return cls
@registered
class Foo(object):
def introduce(self):
return "I'm a Foo"
@registered
class Bar(object):
def introduce(self):
return "I'm a Bar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment