, Python, , Foo bar(self) , , instancemethod, "" , foo_inst.bar() Foo.bar(foo_inst).
class Foo(object):
def bar(self):
print "called bar on %s" % self
foo_inst = Foo()
foo_inst.bar()
Foo.bar(foo_inst)
, :
>>> Foo.bar
<unbound method Foo.bar>
>>> Foo().bar
<bound method Foo.bar of <__main__.Foo object at 0x10675ecd0>>
, , bar self, Foo , self , .
, self , arg0 ( stifflersmom allyourbase).
. Python @https://docs.python.org/2/howto/descriptor.html , , .
, , :
class Foo(object):
pass
def bar(arg0):
print "called bar with %s" % arg0
Foo.bar = bar
Foo().bar()
. ( monkeypatching) , Python, A) ( - , , , ) B) ( , , , /IDE, ).