R. David Murray added the comment:

That's actually a very good question.  hasattr returns False, but is it 
supposed to be an invariant that if dir returns a string hasattr should return 
True and getattr should not return AttributeError?  (Well, it might raise 
AttributeError from inside the attribute, but the attribute itself should be 
"real".)  Or to put it the other way, if hasattr returns False, should it be an 
invariant that dir does not list that attribute name?

This may be a question for python-dev, and the answer may well be that we do 
*not* want to suggest that such an invariant should be expected.  (We of course 
don't enforce such things, but we do make them hold true in the stdlib if we 
establish them).  However, it is certainly a surprising behavior, and Python 
*generally* tries to avoid such surprises.

This may have already been discussed and decided at some previous point, so 
someone should do some docs and archive searching about it first :)

----------
nosy: +r.david.murray

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30554>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to