code blocks in Python

JCM joshway_without_spam at myway.com
Mon Nov 24 12:28:57 EST 2003


JCM <joshway_without_spam at myway.com> wrote:
> Hung Jung Lu <hungjunglu at yahoo.com> wrote:
> ...

>> It just occurred to me a better syntax:

>> def A:
>>     x = 1
>>     y = 2

>> def B:
>>     z = x + y
>>     print z

>> No new keyword needed, beside, it uses the same keyword as function
>> definition, so the purpose of the code block is clear: it's something
>> that you will invoke.

> I dislike this because it looks too much like function definition
> (which I realize was your intent).  The problem is that name-lookup in
> function bodies is lexical, but the proposed semantics for name-lookup
> in codeblocks is dynamic.

Sorry, that was badly worded.  Take 2:

The problem is that name-lookup in function bodies is lexical at the
point of definition, but the proposed semantics for name-lookup in
codeblocks is lexical at the point of use.




More information about the Python-list mailing list