code blocks in Python
JCM
joshway_without_spam at myway.com
Mon Nov 24 11:33:11 EST 2003
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.
More information about the Python-list
mailing list