On Mon, Feb 26, 2018 at 2:37 PM, Ian Kelly <ian.g.ke...@gmail.com> wrote: > On Mon, Feb 26, 2018 at 1:09 PM, <marco.naw...@colosso.nl> wrote: >> def foo(self, *args, **kwargs): >> assert len(args) == 0 > > Better: > > def foo(self, **kwargs): > >> So, use the inspect module to detect the valid arguments >> from the class initializer. Then use **kwargs in every >> class method. It would be nice if the full method signature >> can be kept, but I have not yet figured out if this is >> possible. > > https://pypi.python.org/pypi/decorator/4.2.1
Also, in Python 3.4+ you can just create a Signature object (either from scratch or by calling inspect.signature()) and then assign it to the function's __signature__ attribute. -- https://mail.python.org/mailman/listinfo/python-list