Revised PEP 318 - Function/Method Decorator Syntax
Ian Bicking
ianb at colorstudy.com
Tue Jun 10 18:03:12 EDT 2003
On Tue, 2003-06-10 at 16:43, Chris Liechti wrote:
> Kevin Smith <Kevin.Smith at sas.com> wrote in news:20030610082514442-
> 0400 at braeburn.themorgue.org:
> > Function/Method Decorator Syntax
> > --------------------------------
> > def foo(self) as synchronized(lock), classmethod:
> > perform method operation
>
> what's with the [] syntax discussed here a week ago?
> it was something like:
>
> def foo(self) [synchronized(lock), classmethod]:
>
> or merging with yours:
>
> def foo(self) as [synchronized(lock), classmethod]:
>
> i think the use of [] is quite logic. it's a _list_ of function decorators.
> and it helps readability, at least the variants should be listed as
> alternatives in the PEP.
But lists aren't used in Python syntax, only in other APIs. *Tuples*
are used, or tuple-like constructs, like:
try:
...
except (IOError, OSError):
...
There's also the question about whether a list is really what you want.
Could you do:
def syncclassmethod(lock):
return [synchronized(lock), classmethod)]
def foo(self) syncclassmethod(lock):
...
That's just bad, but disallowing that seems arbitrary. But disallowing
a (non-literal) tuple seems much more reasonable.
Ian
More information about the Python-list
mailing list