سؤال

Take a simple example in :

>>> class A(object):
...     pass
...
>>> def f(self):
...     print "f called"
...
>>> A.f = f
>>> a = A()
>>> a.f()
f called

So in this example, the already existing class A gets an additional (instance) function f (though overriding existing ones works just as well). In real life this would of course happen e.g. in different modules. But how is this procedure called?

هل كانت مفيدة؟

المحلول

Not sure I am following you, but if I do, you are talking about extension methods

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top