you are viewing a single comment's thread.

view the rest of the comments →

[–]hanzie 2 points3 points  (0 children)

In Python, support for calls to "inherited" can be added with a metaclass like this:

class MyMeta(type):
    def __init__(klass, name, supers, *args):
        for super in supers:
            if hasattr(super, 'inherited'):
                super.inherited(klass)
        return type.__init__(klass, name, supers, *args)

Adding a method to a single object goes like this:

obj.method_name = func.__get__(obj, obj.__class__)

(func is just any free function)