[Python-Dev] Extended Function syntax
M.-A. Lemburg
mal@lemburg.com
Thu, 23 Jan 2003 17:12:22 +0100
Guido van Rossum wrote:
>>>>In particular:
>>>>
>>>> def name(arg, ...) [expr1, expr2, expr3]:
>>>> ...body...
>>>>
>>>>would be equivalent to (some variation on):
>>>>
>>>> def name(arg, ...):
>>>> ...body...
>>>>
>>>> name=expr1(expr2(expr3(name)))
>>>
>>>With Michael's patch (which indeed still works) it's actually
>>>
>>> name = expr3(expr2(expr1(name)))
>>
>>I can't remember if that was deliberate or accidental. I think
>>deliberate.
>
>
> It certainly surprises me less -- this is left-to-right (applying
> expr1 first) which is goodness.
+1
I suppose the following would also be possible, provided
that types(...) returns a callable, right ?
def myfunc(x,y,z) [types(int, int, float), cacheglobals]:
return math.sin(x*y/z)
.... and cacheglobals would be able to rewrite the byte
code too. Nice :-)
--
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting: http://www.egenix.com/
Python Software: http://www.egenix.com/files/python/