syntax for code blocks

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Apr 27 12:07:53 EDT 2012


On Fri, 27 Apr 2012 17:03:19 +0200, Kiuhnm wrote:

> On 4/27/2012 16:09, Steven D'Aprano wrote:
>> On Fri, 27 Apr 2012 13:24:35 +0200, 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)
>>
>>
>> I'm sorry, I don't see how this is a code block. Where is the code in
>> the block, and how can you pass it to another object to execute it?
> 
> Maybe if you read the entire post...

No, I read the entire post. It made no sense to me. Let me give one 
example. You state:

    The full form is equivalent to
         def anon_func(x, y):
             print(x, y)
         res = func(arg1, block_name = anon_func)

but this doesn't mean anything to me. What's func? Where does it come 
from? What's arg1? Why does something called block_NAME have a default 
value of a function instead of a NAME?

How about you give an actual working example of what you mean by a code 
block and how you use it?


-- 
Steven



More information about the Python-list mailing list