Antoon Pardon wrote:
Op 2005-03-18, Jeff Shannon schreef <[EMAIL PROTECTED]>:

I find it odd that you start by saying you still find them very
consistent and here state there is a slight inconsistency.

I said that the way that binding a name on a class instance always creates an instance attribute regardless of the presence of a similarly-named class attribute is consistent with the way that name binding works in any scope. This is true. Binding of a name within a function-local scope works the same way -- bindings are always created within the narrowest scope unless something is explicitly done to force other behavior.


You pointed out a case in which class/instance attributes behave slightly differently than local/global names do, and I agree with you that there is a difference in behavior there. However, that difference is in the way that bare names are resolved into local/global references, and *not* in the way that name binding works. The name binding rules are consistent; the inconsistency is in name *lookups*, and is a case of strong optimization of the standard case affecting the behavior of an unusual (and strongly discouraged) case. There is a slight inconsistency in something *other* than what the O.P. was complaining about being inconsistent; I'm recognizing that inconsistency at the same time as I'm attempting to point out that the other "inconsistency" really *is* consistent. (I'm also pointing out that this name-lookup inconsistency is a good example of "practicality beats purity", because the value of the optimization is, IMO, much greater than the cost of the inconsistency.)

Jeff Shannon

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to