[issue11988] special method lookup docs don't address some important details

2011-05-03 Thread R. David Murray
R. David Murray added the comment: Ah, that's what my problem is. My test example was poorly conceived (I used __del__!) so I *thought* the other special methods were triggering getattr. I'd have figured it out if I hadn't screwed up my test :( -- resolution: -> invalid stage: needs

[issue11988] special method lookup docs don't address some important details

2011-05-03 Thread R. David Murray
R. David Murray added the comment: Well, then I suppose my question is why isn't __contains__ looked up? Other special methods that don't exist on Y do cause __getattr__ to be called. Why is __contains__ special? The docs for __getattr__ don't hint at this possibility either. I think the

[issue11988] special method lookup docs don't address some important details

2011-05-03 Thread Georg Brandl
Georg Brandl added the comment: Not sure I understand your issue here. How should "1 in y" get at X.__contains__ given the special method lookup rules? The __getattr__ is not called since y.__contains__ isn't looked up. -- nosy: +georg.brandl ___

[issue11988] special method lookup docs don't address some important details

2011-05-03 Thread Eric Snow
Eric Snow added the comment: In 2.7 I get the following (if Y does not inherit from object): >>> print('res:', 1 in y) ('X contains:', 1) ('res:', False) This makes sense with old style classes. With Y(object): >>> print('res:', 1 in y) Y iter ('res:', True) -- nosy: +ericsnow

[issue11988] special method lookup docs don't address some important details

2011-05-03 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: docs@python -> rhettinger nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list ma

[issue11988] special method lookup docs don't address some important details

2011-05-03 Thread Andreas Stührk
Changes by Andreas Stührk : -- nosy: +Trundle ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pytho

[issue11988] special method lookup docs don't address some important details

2011-05-03 Thread R. David Murray
New submission from R. David Murray : The following code: class X(list): def __contains__(self, key): print('X contains:', key) class Y(): def __init__(self, x): self.x = x def __getattr__(self, key): return getattr(self.x