3 ms·
Yeah, one most complex way to do it. I just tested my assertion for the sake of truth and it seems correct: class Foo: def bar(self, x): prin
by wruza 8y ago
Yeah, one most complex way to do it. I just tested my assertion for the sake of truth and it seems correct:
class Foo:
def bar(self, x):
print 'bar', x
def f(x): print 'f', x
foo = Foo()
foo.baz = f
print(foo.bar) # <bound method Foo.bar of <__main__.Foo object>>
print(foo.baz) # <function f>
foo.bar(5) # bar 5
foo.baz(6) # f 6
Now who wants to say that 'js this' is quirky and complicated?