Skip to content

Instantly share code, notes, and snippets.

@c0nrad
Created May 19, 2013
Embed
What would you like to do?
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