[Python-Dev] PEP 318 restrictions on elements (original) (raw)
[Python-Dev] PEP 318 - generality of list; restrictions on elements
Jeff Epler jepler at unpythonic.net
Mon Mar 8 16:29:54 EST 2004
- Previous message: [Python-Dev] PEP 318 - generality of list; restrictions on elements
- Next message: [Python-Dev] Re: PEP 318 - generality of list; restrictions on elements
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In the suggested syntaxes, the modifiers are not a list. There's no list here: >>> def f() [wrapper]: pass just like there's no tuple* in either of these (or the above): >>> def f(x, y): pass >>> class C(A, B): pass and you can't just say >>> s1 = (x, y) >>> def f s1: pass or >>> s2 = (A, B) >>> class C s2: pass
I don't think there'll be any trouble becoming accustomed to this new syntax, with something "a lot like a list literal (but not quite)".
The answer to any of the specific questions you posed is answered by the PEP's new grammar rule. As I understand it, the items must be callable, they may return anything, and they must take the output from the inner modifier function (a function object in the case of the earliest-called modifier). For instance, the following would be permitted (but probably not encouraged):
>>> def call(f): return f()
>>> def pi() [call]:
... return math.atan(1) * 4
>>> pi
3.1415926535897931
Jeff
- Previous message: [Python-Dev] PEP 318 - generality of list; restrictions on elements
- Next message: [Python-Dev] Re: PEP 318 - generality of list; restrictions on elements
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]