[Python-ideas] Multiple arguments for decorators

Chris Angelico rosuav at gmail.com
Mon Nov 30 21:03:52 EST 2015


On Tue, Dec 1, 2015 at 12:54 PM, Cem Karan <cfkaran2 at gmail.com> wrote:
> I like this; it really SHOULD be indented.  But I also agree that 'with' is probably not the best keyword here, it makes it a little difficult to quickly read and see what's going on.  Since this is for decorators, could we just drop 'with' altogether?  E.g.:
>
> class Foo:
>    def __init__(self):
>        self._x = 42
>    @property as x:
>        def fget(self):
>            return self._x
>        def fset(self, value):
>            self._x = value
>        def fdel(self):
>            del self._x
>
> Thanks,
> Cem Karan

Either way works for me. My first try was some kind of hack that
actually used a context manager as a context manager, but without
compiler support, it wouldn't really work properly. So the syntax can
be varied away from 'with'.

ChrisA


More information about the Python-ideas mailing list