def method(cls): """Adds the function as a method to the given class.""" import new def _wrap(f): cls.__dict__[f.func_name] = new.instancemethod(f,None,cls) return None return _wrap