syntax for code blocks

Kiuhnm kiuhnm03.4t.yahoo.it
Fri Apr 27 07:24:35 EDT 2012


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?

Kiuhnm



More information about the Python-list mailing list