[Python-Dev] statically nested scopes

Tim Peters tim_one@email.msn.com
Thu, 2 Nov 2000 16:13:47 -0500


[Jeremy]
> Looks like we need to rehash this thread at least enough to determine
> who is responsible for causing us to rehash it.
>
> MAL said it would break code.  I asked how.  Skip and Tim obliged with
> examples.  I said their examples exhibited bad style; neither of them
> claimed they were good style.

Ah!  I wasn't trying to give an example of code that would break, but, ya,
now that you mention it, it would.  I was just giving an example of why
visual inspection will be harder in Python than in Pascal.

I expect that the kind of code I showed *will* be common: putting all the
nested "helper functions" at the top of a function, just as was also done in
Pascal.  The killer difference is that in Pascal, the containing function's
locals referenced by the nested helpers can be found declared at the top of
the containing function; but in Python you'll have to search all over the
place, and if you don't find a non-local var at once, you'll be left uneasy,
wondering whether you missed a binding target, or whether the var is truly
global, or what.