[docs] [issue23987] docs about containers membership testing wrong for broken objects

Raymond Hettinger report at bugs.python.org
Tue Apr 21 04:30:09 CEST 2015


Raymond Hettinger added the comment:

There is a separate report for taking care of the identity check for contains:  https://bugs.python.org/issue23986

I think notes about crazy hashes shouldn't spill all over our docs.  At best, it warrants a FAQ entry about how hash tables work.

The risk here is that in an effort to be more precise, it is easy impair the usability of the docs.  The wording in question has been around for a very long time and has overall done a good job of explaining the intent of the in-operator to all but the most pedantic reader, "The operators 'in' and 'not in' test for membership. 'x in s' evaluates to true if x is a member of s, and false otherwise."

If you really want to be precise, the *only* thing that can be broadly stated about the in-operator is that it calls __contains__ on an object that that object can implement whatever logic it wants (hash table lookup, linear search, google search, random result, etc).  But then, this is no different than most magic methods in that regard.

----------
assignee: docs at python -> rhettinger
nosy: +rhettinger

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23987>
_______________________________________


More information about the docs mailing list