Skip to content

Instantly share code, notes, and snippets.

@richo
Created April 11, 2013 06:43
Show Gist options
  • Select an option

  • Save richo/5361247 to your computer and use it in GitHub Desktop.

Select an option

Save richo/5361247 to your computer and use it in GitHub Desktop.
class Foo(object):
def method(self, foo):
def _(n):
print repr(self)
print repr(n)
return _
class Butts(object):
def __getattr__(self, n):
return self.__getattribute__("_" + n)
@staticmethod
def foo(arg):
print repr(arg)
## equavillent t
def _(arg):
print repr(arg)
foo = staticmethod(_)
foo = Foo()
foo.thing = foo.method("butts")
foo.thing("lols") # meth's definition has access to self via local scope
Butts.foo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment