Skip to content

Instantly share code, notes, and snippets.

@Excedrin
Created November 1, 2014 04:32
Show Gist options
  • Save Excedrin/49c0a0c850f6e5015026 to your computer and use it in GitHub Desktop.
Save Excedrin/49c0a0c850f6e5015026 to your computer and use it in GitHub Desktop.
def selfdec(f):
def dec(*x, **kwa):
f.__globals__['self'] = x[0]
return f(*x[1:], **kwa)
return dec
class X():
@selfdec
def z(more, args, even="opt"):
self.hurr = 3
return "%s: %d" %(even, self.hurr + more + args)
a = X()
print a.z(1,2,even="test")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment