Skip to content

Instantly share code, notes, and snippets.

@c0nrad
Created May 19, 2013 23:11
Show Gist options
  • Save c0nrad/5609462 to your computer and use it in GitHub Desktop.
Save c0nrad/5609462 to your computer and use it in GitHub Desktop.
class Lol:
pass
lol = Lol()
functions = ["print_hai", "print_bai", "print_meow", "print_lulz"]
for func in functions:
printValue = func.split('_')[1] # hai, bai, meow
setattr(lol, func, lambda printValue=printValue: print(printValue))
lol.print_hai()
lol.print_bai()
lol.print_meow()
lol.print_lulz()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment