Skip to content

Instantly share code, notes, and snippets.

@mike-burns
Created September 5, 2013 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mike-burns/6455313 to your computer and use it in GitHub Desktop.
Save mike-burns/6455313 to your computer and use it in GitHub Desktop.
Example builder pattern in Python
class ThingyMaker(object):
def __init__(self):
self.thingy = None
self.widget = None
def with_thingy(self, thingy):
self.thingy = thingy
return self
def with_widget(self, widget):
self.widget = widget
return self
def make_thingy(self):
return Thingy(self.thingy, self.widget)
class Thingy(object):
def __init__(self, thingy, widget):
self.thingy = None
self.widget = None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment