This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ezio.melotti
Recipients christian.heimes, docs@python, ezio.melotti, nparikh
Date 2012-09-24.05:42:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1348465341.4.0.0180420280326.issue16011@psf.upfronthosting.co.za>
In-reply-to
Content
http://docs.python.org/py3k/reference/datamodel.html#object.__contains__ says that __contain__ "Should return true if item is in self, false otherwise.".  Here the lowercase true and false mean any true or false value, not just True and False and it's indeed possible to return any value.

The fact that 'in' only returns True/False, possibly converting the return value of __contains__, should be documented in the 'in' documentation.
http://docs.python.org/py3k/reference/expressions.html#membership-test-details says "For user-defined classes which define the __contains__() method, x in y is true if and only if y.__contains__(x) is true.".  This could be changed to say that the return value is converted to True/False.
History
Date User Action Args
2012-09-24 05:42:21ezio.melottisetrecipients: + ezio.melotti, christian.heimes, docs@python, nparikh
2012-09-24 05:42:21ezio.melottisetmessageid: <1348465341.4.0.0180420280326.issue16011@psf.upfronthosting.co.za>
2012-09-24 05:42:20ezio.melottilinkissue16011 messages
2012-09-24 05:42:20ezio.melotticreate