On 03/01/2018 10:34 AM, Gregory Ewing wrote:
After this thread, the term "docstring" is never going to mean quite the same thing to me again.
I still feel that the following is quite readable: <-----------------------------------> import inspect def snatch(func): def snatched(self, *args, **kwargs): signature = inspect.signature(func) for name in signature.parameters: if name != 'self': kwargs.setdefault(name, getattr(self, name)) return func(self, *args, **kwargs) return snatched class Foo(object): def __init__(self, sleepy, groggy): self.sleepy = sleepy self.groggy = groggy @snatch def spam(self, sleepy=None): print("I am spam. sleepy=", sleepy) @snatch def ham(self, sleepy=None, groggy=None): print("I am ham. sleepy=", sleepy, " and groggy=", groggy) <--------------------------------------> -- ~ Jugurtha Hadjar, -- https://mail.python.org/mailman/listinfo/python-list