syntax for code blocks

Ethan Furman ethan at stoneleaf.us
Sat Apr 28 16:52:45 EDT 2012


Kiuhnm wrote:
> I'd like to change the syntax of my module 'codeblocks' to make it more 
> pythonic.
> 
> Current Syntax:
> 
>     with res << func(arg1) << 'x, y':
>         print(x, y)
> 
>     with res << func(arg1) << block_name << 'x, y':
>         print(x, y)
> 
> New Syntax:
> 
>     with res == func(arg1) .taking_block (x, y):
>         print(x, y)
> 
>     with res == func(arg1) .taking_block (x, y) as block_name:
>         print(x, y)
> 
> The full form is equivalent to
> 
>     def anon_func(x, y):
>         print(x, y)
>     res = func(arg1, block_name = anon_func)
> 
> Suggestions?

I don't find either the current syntax nor the new syntax pythonic.

~Ethan~



More information about the Python-list mailing list