Skip to content

Instantly share code, notes, and snippets.

@binarymatt
Last active January 2, 2016 12:39
Show Gist options
  • Save binarymatt/8305119 to your computer and use it in GitHub Desktop.
Save binarymatt/8305119 to your computer and use it in GitHub Desktop.
factory method
from .base import AbstractTariff
from .us import USTariff
from .ca import CATariff
def factory(name):
mod = sys.modules[__name__]
classname = '{}Tariff'.format(name)
return getattr(mod, classname, None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment