Really stupid question regarding PEP 252 and type/class unification

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Thu Aug 23 17:00:15 EDT 2001


Thu, 23 Aug 2001 19:30:44 GMT, Bengt Richter <bokr at accessone.com> pisze:

>     lhs = rhs
> Is it cast in concrete *for always and forever* that the
> old binding of the lhs will *always* be discarded in favor of a new
> binding to the rhs without regard to the previous binding?

I think yes. The old binding doesn't need to exist at all.

In order to change this the local namespace would have to be controlled
by something other than a dictionary. (Now it's not really implemented
using a dictionary, except special cases, but it behaves like a
dictionary, except that all changes must be done using variable
binding syntax instead of setitem.)  Currently it must be a dictionary.

Or perhaps there could be another variant of 'global' declaration
which delegates bindings of a particular variable from the local
namespace to something else. Currently 'global' is about the only
thing which changes the meaning of the plain name binding, and it
only switches the namespace, keeping similar rules.

I don't believe that the standard local namespace would ever behave
differently for name rebinding for implicitly declared variables.

> IOW, one could conceive of a check for an attribute of the old
> binding's object which if present would mean that the old object
> gets to handle the reference to the new rhs and leave the old
> binding alone.

IMHO it would be confusing to have an extremely rare case where the
= operator means something different. I would not use this operator
for this case. It always meant rebinding of a name. The old binding
is irrelevant - the object doesn't need to exist at all.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list