Skip to content

Instantly share code, notes, and snippets.

@willrjmarshall
Created April 18, 2012 05:46
Show Gist options
  • Save willrjmarshall/2411343 to your computer and use it in GitHub Desktop.
Save willrjmarshall/2411343 to your computer and use it in GitHub Desktop.
# this is really verbose #####################################################################
class ConfigureMyApp(object):
def init(self):
Looper(height = get_height(), width = get_width())
class Looper:
def init(self, height = None, width = None):
self.set_height(height)
self.set_width(width)
def set_height(self, height):
# Do something clever with subclasses here
# This is much better #####################################################################
class ConfigureMyApp(object):
def init(self):
self.looper = Looper()
self.looper.configure |l|
l.set_height(get_height)
l.set_width(get_width)
class Looper(object):
def configure(self, a_function):
a_function(self)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment