bpo-30803: clarify truth value testing documentation#2508
Conversation
There was a problem hiding this comment.
- any empty set or mapping, for example,
set(),{}.
There was a problem hiding this comment.
I much prefer a minimal change, adding "set or" and "set(), "
|
This PR has both the "CLA signed" and the "CLA not signed" labels. Is it Schrödinger's CLA? ;) |
|
@terryjreedy Well, I'm not sure what to do at this point. I adapted the proposal by @rhettinger who is also a very experienced Python contributor. I found this a very reasonable course of action. Now you say that you "much prefer a minimal change" while putting forward zero arguments (not even a subjective one). On bpo, you also said very broadly that you would not merge this patch. It's true that patches don't need to be accepted, but it's also true that a community works better if a contribution is valued, and criticism is backed by an argument. Other people may "much prefer" concise documentation. The previous phrasing was not concise, and I can't following the reasoning for keeping something just because the change would be minimal. In fact, one may argue that this is a good moment to rephrase the whole thing, as we're touching it anyways. |
There was a problem hiding this comment.
I strongly prefer 'collection' rather than 'container'. Collections do not 'contain' python objects. They may contain references to objects, values corresponding to objects, or info needed to generate objects by algorithm.
There was a problem hiding this comment.
That aside, Raymond's wording is clearer, simpler, and more complete than your rewrite. Use what he wrote.
There was a problem hiding this comment.
I don't see why one can't say 'container' even if the structure may 'contain' entities beyond Python objects. There is still something contained within; further, nobody claimed them to be 'object containers' only or made some other implicit restriction.
Similarly: Does a 'collection' only 'collect' Python objects? (Does it actually 'collect' anything?)
Anyhow, the docs use 'collection' and 'container' pretty much interchangeably, and I consider this point completely moot. However, you certainly have better understanding, so I used now what you strongly and wisely preferred, hence graciously commanded me to. I hope we now all agree on this matter.
There was a problem hiding this comment.
@peterthomassen just FYI, 'collection' is technically correct here and 'container' is technically wrong, since the Container abc only requires __contains__ to be defined, which if nothing else was defined would make the object true. A Collection, on the other hand, is sized, and so can be false if empty.
You are right, however, that we do sometimes use them interchangeably. But we probably shouldn't :)
Thanks for taking the time to work through this PR.
There was a problem hiding this comment.
@bitdancer Thank you for sharing your knowledge. I understand your point (which is technical, not just semantic), and agree that as a consequence, 'empty container' is not a very good term if a Container type is not required to have __len__ defined. (As an aside, isinstance(set(), collections.abc.Container) is still true, and the same is the case for the other empty collections listed in the docs section this PR deals with.)
I guess it is not defined whether 'container' and 'collection' mean Container and Collection, respectively (but I don't feel this needs to be rectified).
There was a problem hiding this comment.
Right, the lower case terms do not necessarily refer to the ABC definitions, but the closer we adhere to those definitions in the docs, the better, probably. The ABCs represent our formal definitions of the terms, as opposed to the colloquial usage.
There was a problem hiding this comment.
I am fussy about the terminology for the practical reason that I regularly see people confused by 'container', including myself as a student long ago when I realized that a set is not like a box or room but a pure conceptual grouping. The issue comes up at least yearly on python-list, where I have been active for over 20 years.
|
|
||
| .. index:: single: true | ||
| * numeric zero of any type: ``0``, ``0.0``, ``0j``, ``Decimal(0)``, | ||
| ``Fraction(0, 1)`` |
There was a problem hiding this comment.
What was wrong with the original wording? And aren’t Decimal and Fraction out of scope of “the built-in objects”?
There was a problem hiding this comment.
See the issue for 'wrong'. Decimal and Fraction are built-in in the sense of C-coded stdlib objects, but not in 'part of builtins' module. I could go either way with them.
There was a problem hiding this comment.
Okay, I see that this wording probably comes from @terryjreedy’s suggestion https://bugs.python.org/issue30803#msg298099, although I don’t see any reasoning. IMO the current zero of any numeric type, or Raymond’s numbers equal to zero, are clearer.
Numeric zero of any type raises the question of what a numeric zero of the string type looks like. I think other languages consider strings with the digit zero to be false. (PHP or Perl perhaps?)
There was a problem hiding this comment.
I agree with changing back to 'zero of any numeric type'. Peter, change this (I cannot, for some reason) and I will merge.
|
Peter, I cannot add commits to this issue, and a few others. Please follow the instructions at https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/#enabling-repository-maintainer-permissions-on-existing-pull-requests to make sure "Allow edits from maintainers." is checked for this and other IDLE issues. Please let me know what you find. If this permission is already granted, then I have some other problem with github. |
|
@terryjreedy Terry, I just checked that "allow edits" box. |
|
GH-2946 is a backport of this pull request to the 3.6 branch. |
The documentation was unclear about the truth value of sets. This PR clarifies the situation, based on a phrasing proposal from https://bugs.python.org/issue30803.
https://bugs.python.org/issue30803