In defence of the two-namespace rule

Dieter Maurer dieter at handshake.de
Thu Jan 20 14:34:46 EST 2000


Edward Welbourne <eddyw at lsl.co.uk> writes on Thu, 20 Jan 2000 14:39:31 +0000:
> Personally, I consider the two-namespace rule to be a
> major *strength* of python: it is a major ingredient in pythonicness.
Me and all my colleagues using Python have already been bitten by this
ingredient -- mostly in connection with "lambda", rarely in connection
with methods ("self" forgotten, module variable used).
I would like to live without it.

> I contend that the namespace in which a function executes its suite
> *should* be discardable at the time the function returns.  Lexical
> scoping would mean that we can't discard foo's namespace when foo
> finishes execution.  The implications of this for garbage collection are
> singularly unpleasant - give them some thought.
As you pointed out in the following paragraph (which I deleted),
the compiler could do automatically, what, now, I must do manually
when I need to access the enclosing objects:
	def bar(...., a=a, b=b, ...)
I admit, that this does not give a true lexical scoping semantics, though
(rebindung of "a" is local to "bar").
I think (but am not sure) that I would be satisfied
with this semantics.

> ...
> but to pythoneers, the two-namespace rule is harmonious,
> beautiful and kind to the garbage-collector.  Treat the humblest of thy
> servants kindly, lest they rise up and smite thee with just zeal.
I feel me as a pythoneer, but nevertheless the two-namespace rule is not
beautiful for me, nor is grouping by indentation.


Dieter



More information about the Python-list mailing list