[Python-Dev] Explicit Lexical Scoping (pre-PEP?) (original) (raw)

Jan Kanis jan-python at maka.demon.nl
Fri Jul 7 01:00:03 CEST 2006


On Thu, 06 Jul 2006 18:28:12 +0200, Phillip J. Eby <pje at telecommunity.com>
wrote:

Here's the reason I think this keeps coming up, and why Guido's "just use a class" argument doesn't really address the actual problem that's taking place.

I agree this argument is not generally applicable in every case, but why
not in this specific situation?

In short: in theory, a rebinding operator or "nonlocal" declaration is unnecessary. In practice, having one seems quite useful every time you wander down the path that leads to having to rewrite your code just because the language won't let you do that one tiny thing -

I think this argument is a too general one. To me it is too close to
"let's add every possible feature we can find, because it might be usefull
to someone" :) One of the things I like about python is that it doesn't do this, and
therefore the manual stays relatively small and I don't have to remember
all kinds of rarely used features to make best use of the language. (I
assume this is not a point of debate. repeating: Python is not Lisp ;-) )

Most of the arguments I've seen on the list are about 'how can we
implement this', I'd like to see more arguments on whether this should be
implemented at all. I was hoping someone would come up with a good example, so does anyone
have one??

- or so it feels like to the person who's experiencing it.

Have you ever been that person, or come across such a situation?

O, and I don't think the inc() example is a good one. In this incrementer
the function call is all about the side effects, it's even in the name
'increment'. Incrementing is useless unless you increment /something/, so
this should be better implemented as a class.



More information about the Python-Dev mailing list