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.

classification
Title: obj.__contains__() returns 1/0...
Type: Stage:
Components: Interpreter Core Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gminick, gvanrossum
Priority: normal Keywords: patch

Created on 2003-10-08 19:52 by gminick, last changed 2022-04-10 16:11 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
py-2.3.2-contains.patch gminick, 2003-10-08 19:52 Patch changing obj.__contains__() to return True/False.
Messages (3)
msg44749 - (view) Author: Wojtek Walczak (gminick) Date: 2003-10-08 19:52
shouldn't it return True/False?

examples:
>>> a = 'python'
>>> a.__contains__('perl')
0
>>> a.__contains__('python')
1
>>> a = { 'python' : 1, 'ruby' : 1 }
>>> a.__contains__('perl')
0
>>> a.__contains__('python')
1
>>>

instead of:

>>> a = 'python'
>>> a.__contains__('perl')
False
>>> a.__contains__('python')
True
>>> a = { 'python' : 1, 'ruby' : 1 }
>>> a.__contains__('perl')
False
>>> a.__contains__('python')
True
>>>

The reason for asking is that i.e. obj.__eq__() returns True/False,
and besides True/False looks nicer than 1/0 ;>
msg44750 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-10-08 20:12
Logged In: YES 
user_id=6380

Looks good, I'll check this in.
msg44751 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-10-08 21:09
Logged In: YES 
user_id=6380

Thanks, checked in!
History
Date User Action Args
2022-04-10 16:11:40adminsetgithub: 39385
2003-10-08 19:52:36gminickcreate