Of course you can do the same without annotations, but with the
introduction of private attribute while your API it is under active
development:

from functools import wraps
def validate(func):
    @wraps(func)
    def _wrap(self, *args, **kwargs):
        variables = self._vars   # Here
        kwargs.update(zip(variables, args))
        for var in variables - kwargs.keys():
            kwargs[var] = getattr(self, var)
        return func(self, **kwargs)
    return _wrap

class Foo:
    def __init__(self, bashful, doc, dopey, grumpy,
                       happy, sleepy, sneezy):
        self.bashful = bashful
        self.doc = doc
        self.dopey = dopey
        self.grumpy = grumpy
        self.happy = happy
        self.sleepy = sleepy
        self.sneezy = sneezy
        self._vars = set(v for v in self.__dict__ if not
v.startswith('_'))   # should be deleted when finish

    @validate
    def spam(self, bashful=None, doc=None, dopey=None,
                   grumpy=None, happy=None, sleepy=None,
                   sneezy=None):

        return bashful, doc, dopey, grumpy, happy, sleepy, sneezy

With kind regards,
-gdg
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to