[Python-Dev] Extended Function syntax

Just van Rossum just@letterror.com
Thu, 23 Jan 2003 09:44:44 +0100


Jim Fulton 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 wonder if the same mechanism could be used in class statements.
> If I had this, I might say what interface a class implements
> with:
> 
>    class foo(spam, eggs) [implements(IFoo, IBar)]:
>       body of class
> 
> or (wo parens):
> 
>    class foo [implements(IFoo, IBar)]:
>       body of class

I don't know how Zope interfaces work, but I can imagine the following
could be made to work as well:

   class foo(spam, eggs) [IFoo, IBar]:
      body of class

I think this would be wonderful. Would someone be interested in
extending Michael's patch to also cover the class statement?

Just