Re: [Python-Dev] Metaclass problem in the "with" statement semantics in PEP 343
Michael Chermside wrote:
Right now, we say that there's one rule for all *normal* attributes and methods, and a slightly different rule for all double-underbar methods.
Guido responded:
But it's not normal vs. __xyzzy__. A specific set of slots (including next, but excluding things like __doc__) get special treatment. The rest don't. All I'm saying is that I don't care to give __context__ this special treatment.
Perhaps we should officially document that the effect on special methods of overriding a class attribute with an instance attribute is undefined, for some given set of attributes? (I would say all double-underbar methods, but it sounds like the list needs to also include next().) Otherwise, it seems like people might write code that relies on the current behavior, which will then break if we eg turn __context__ into a slot. (It sounds like you want to reserve the right to change this.) Well, of course, people may rely on the current behavior anyway, but at least they'll have been warned. :) -Edward
Edward Loper wrote:
Otherwise, it seems like people might write code that relies on the current behavior, which will then break if we eg turn __context__ into a slot. (It sounds like you want to reserve the right to change this.) Well, of course, people may rely on the current behavior anyway, but at least they'll have been warned. :)
Yep - I thought "the instance dictionary has no effect" was an actual rule, but it turns out the rules are slightly looser than that (specifically, that fact that the effect of having a slot name in the instance dictionary is undefined). Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org
participants (2)
-
Edward Loper
-
Nick Coghlan