[Python-Dev] anonymous blocks

Brian Sabbey sabbey at u.washington.edu
Tue Apr 19 21:11:01 CEST 2005

Shannon -jj Behrens wrote:
> Have you guys considered the following syntax for anonymous blocks?  I
> think it's possible to parse given Python's existing syntax:
>   items.doFoo(
>       def (a, b) {
>           return a + b
>       },
>       def (c, d) {
>           return c + d
>       }
>   )

There was a proposal in the last few days on comp.lang.python that allows 
you to do this in a way that requires less drastic changes to python's 
syntax.  See the thread "pre-PEP: Suite-Based Keywords" (shamless plug) 
(an earlier, similar proposal is here: 
%40python.org ).

In short, if doFoo is defined like:

def doFoo(func1, func2):

You would be able to call it like:

 	def func1(a, b):
 		return a + b
 	def func2(c, d):
 		return c + d

That is, a suite can be used to define keyword arguments.


More information about the Python-Dev mailing list