[issue28617] Why isn't "in" called a comparison operation?

2020-01-08 Thread wim glenn


Change by wim glenn :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2018-09-11 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Humm, why the bot merges in the master branch?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2018-09-11 Thread miss-islington


miss-islington  added the comment:


New changeset 889f080a4d5cdb1cfb901b953f4b89f3ea806bbe by Miss Islington (bot) 
in branch '3.6':
bpo-28617 Fixed docs inaccuracies about the types that support membership tests 
(GH-9086)
https://github.com/python/cpython/commit/889f080a4d5cdb1cfb901b953f4b89f3ea806bbe


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2018-09-11 Thread miss-islington


miss-islington  added the comment:


New changeset 3e648f8371e342ccfa663ad77e82a538fcc8c9fb by Miss Islington (bot) 
in branch '3.7':
bpo-28617 Fixed docs inaccuracies about the types that support membership tests 
(GH-9086)
https://github.com/python/cpython/commit/3e648f8371e342ccfa663ad77e82a538fcc8c9fb


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2018-09-11 Thread miss-islington


Change by miss-islington :


--
pull_requests: +8612

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2018-09-11 Thread miss-islington


Change by miss-islington :


--
pull_requests: +8613

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2018-09-11 Thread miss-islington


miss-islington  added the comment:


New changeset 08bcf647d8a92e4bd47531588b284c6820b7a7ef by Miss Islington (bot) 
(wim glenn) in branch 'master':
bpo-28617 Fixed docs inaccuracies about the types that support membership tests 
(GH-9086)
https://github.com/python/cpython/commit/08bcf647d8a92e4bd47531588b284c6820b7a7ef


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2018-09-11 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I think that "types that are :term:`iterable` or implement the 
:meth:`__contains__` method" is too low-level for this section.

In this section we tell about builtin types. From those the types that support 
`in` and `not in` are list, tuple, dict, set, frozenset, str, bytes, bytearray, 
memoryview, and iterator types. We can just enumerate them or use general word. 
Calling the "sequence types" is not correct, but fortunately all of them are 
iterable, so that we can say just "iterable types described below". Or 
enumerate categories of types, as they are named in the below subsections: 
"iterator types, sequence types, str, binary sequence types, set types and 
dict", with links to corresponding subsections.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2018-09-06 Thread wim glenn


Change by wim glenn :


--
pull_requests: +8545
stage: commit review -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2017-11-16 Thread Nick Coghlan

Nick Coghlan  added the comment:

Also see https://bugs.python.org/issue32055 regarding the prospect of bringing 
the implementation into line with the intuitive semantics, and preventing 
implicit comparison chaining for containment tests.

--
nosy: +ncoghlan

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2016-12-05 Thread wim glenn

wim glenn added the comment:

1 month later.. is newpatch.diff OK to merge or any further improvements 
needed?  thanks

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2016-11-11 Thread Terry J. Reedy

Terry J. Reedy added the comment:

"Two more operations with the same syntactic priority, in and not in, are 
supported ..."

could be changed to

The containment tests in and not in have the same priority as comparisons and 
are supported ..."

--
nosy: +terry.reedy
stage:  -> commit review
versions:  -Python 3.3, Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2016-11-05 Thread Raymond Hettinger

Raymond Hettinger added the comment:

newpatch.diff looks fine.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2016-11-04 Thread Fred L. Drake, Jr.

Fred L. Drake, Jr. added the comment:

"in" and "not in" are not comparisons, regardless of implementation mechanics 
(which could change).

They aren't really dependent on iteration, though they often correlate with 
iteration.

I'd rather see them described as "containment tests" or something similar.

--
nosy: +fdrake

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2016-11-04 Thread wim glenn

wim glenn added the comment:

Perhaps it's better to call a spade a spade here - if they're implemented as 
comparisons, then why not document them as comparisons?

A colleague has mentioned one point that sets `in` and `not in` apart from the 
other comparisons in the table: comparisons are generally made between objects 
of the same type (with the exception of numbers).  But membership "comparisons" 
are made between different types (with the exception of substring checks).  

Here is an alternate patch which leaves the table alone, but corrects the 
inaccuracy in the note.

--
Added file: http://bugs.python.org/file45360/newpatch.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2016-11-04 Thread Raymond Hettinger

Raymond Hettinger added the comment:

At a grammar and implementation level, the "in" and "not in" operators are 
treated like comparisons (same precedence and opcodes), but at a semantic 
level, I concur with David Murray and don't think of these as being comparisons 
at all.   Accordingly, I prefer the current presentation
and agree with David that the note should be revised to say "only by types that 
support iteration".

--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2016-11-04 Thread wim glenn

wim glenn added the comment:

I want to add that the grammar explicitly mentions them as comparisons

https://docs.python.org/3/reference/grammar.html

And they are also listed in the comparisons section of the expressions 
documentation

https://docs.python.org/3/reference/expressions.html#comparisons

So the docs seem to be contradicting themselves here.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2016-11-04 Thread wim glenn

wim glenn added the comment:

Well, that wouldn't be true either.  Because you can easily implement objects 
which support membership tests but don't support iteration.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2016-11-04 Thread R. David Murray

R. David Murray added the comment:

It should really say "only by types that support iteration".  They are not 
comparison operations, they are containment predicates.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28617] Why isn't "in" called a comparison operation?

2016-11-04 Thread wim glenn

New submission from wim glenn:

Regarding 

https://docs.python.org/3/library/stdtypes.html#comparisons

There is a line at the bottom claiming:

> Two more operations with the same syntactic priority, in and not in, are 
> supported only by sequence types (below).

The claim is incorrect because `in` and `not in` are also supported by 
non-sequence types such as sets, mappings, etc for membership testing.

Is there any good reason why we don't include them in the table of comparison 
operations, and say that there are ten comparison operations in python?  They 
do support comparison chaining in the same way: 

>>> 'x' in 'xy' in 'xyz'
True
>>> 0 in {0} in [{0}]
True

--
assignee: docs@python
components: Documentation
files: patch.diff
keywords: patch
messages: 280080
nosy: docs@python, wim.glenn
priority: normal
severity: normal
status: open
title: Why isn't "in" called a comparison operation?
type: enhancement
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7
Added file: http://bugs.python.org/file45359/patch.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com