Neal Norwitz wrote:
> [Georg]
> This is modeled after the principle that for new-style objects, __special__
> methods are looked up on the type, not the instance.
> 
> -----
> 
> 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.

Cheers,
Nick.

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org
_______________________________________________
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

Reply via email to