Skip to content

Instantly share code, notes, and snippets.

@lov3catch
Created July 20, 2015 15:02
Show Gist options
  • Save lov3catch/99ef8f9aac09bbfa3d00 to your computer and use it in GitHub Desktop.
Save lov3catch/99ef8f9aac09bbfa3d00 to your computer and use it in GitHub Desktop.
data = [2, 3]
# actions
def aaa(data):
return [i+'_aaa' for i in data()]
def bbb(data):
return [i+'_bbb' for i in data()]
# templates
def template_a(data, action):
print 'run template A'
print action(data)
def template_b(data, action):
print 'run template B'
print action(data)
# data
def data_a():
return ['a', 'b', 'c']
def data_b():
return ['c', 'b', 'a']
def template_maker(tmplt, action, data):
def template():
tmplt(data, action)
return template
templates = [template_maker(t, a, d)
for t in (template_a, template_b)
for a in (aaa, bbb)
for d in (data_a, data_b)]
print templates
for t in templates:
t()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment