def method_of(instance):

    def method_adder(function):
        setattr(instance, function.__name__, function)
return function
return method_adder

@method_of(a)
def new_func(arg1, arg2):
    stuff()
Assigning method to object at runtime in Python