On 3/14/07, Nick Coghlan <[EMAIL PROTECTED]> wrote: > > 1) I didn't remember this, do we have it documented somewhere? > > 2) Assuming #1 is correct, is this rule consistently applied? > > 3) How does (should) this affect 2.6 and migration to 3.0, if at all? > > The principle isn't consistently applied - the with statement generates > standard GET_ATTR opcodes, so it checks the instance first when looking > for __enter__ and __exit__. > > It was questioned at the time, and Guido was OK with it - I believe his > position was that defining special methods on instances may or may not > affect behaviour, and whether or not it does so is implementation dependent.
Right. At the same time, we could be more rigorous in 3.0 if we wanted to. We could even do this by hacking the default getattr implementation to skip the instance dict if the name starts and ends with two underscores. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
