[issue30803] Truth value of sets not properly documented

2017-06-29 Thread Peter Thomassen

New submission from Peter Thomassen:

The truth value of sets is not properly documented, in particular regarding 
whether an empty set is considered false or not.

Ignoring primitive (such as numerals) as well as user-defined types, 
https://docs.python.org/3/library/stdtypes.html#truth says:

> The following values are considered false:
> 
> - [...]
> - any empty sequence, for example, '', (), [].
> - any empty mapping, for example, {}.
> - [...]
> 
> All other values are considered true

According to 
https://docs.python.org/3/library/stdtypes.html#sequence-types-list-tuple-range,
 a set is not a sequence (it is unordered, its elements do not have indices, 
etc.):

> There are three basic sequence types: lists, tuples, and range objects.

And, according to 
https://docs.python.org/3/library/stdtypes.html#mapping-types-dict,

> There is currently only one standard mapping type, the dictionary.

So, as per the documentation, the set type is not a type that can ever be 
False. However, when I try, bool(set()) evaluates to False.

When I asked this on Stack Overflow, someone checked in the CPython code and 
judged that this is most likely a mere documentation issue: 
https://stackoverflow.com/a/44813565/6867099

--
assignee: docs@python
components: Documentation
messages: 297268
nosy: docs@python, thomassen
priority: normal
severity: normal
status: open
title: Truth value of sets not properly documented
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7

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



[issue30803] Truth value of sets not properly documented

2017-06-30 Thread Peter Thomassen

Peter Thomassen added the comment:

I submitted a PR on github, and signed the CLA before doing so. (I 
double-checked my bpo username in the CLA, and my github username in the bpo 
profile.) Still, the bot says I need to sign the CLA. I'm not sure what to do?

--

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



[issue30803] Truth value of sets not properly documented

2017-07-13 Thread Peter Thomassen

Peter Thomassen added the comment:

I like your most recent suggestion, and updated the PR after fixing a typo 
('Fractions') and making it more complete (complex numbers).

Let me know if anything else is needed.

(A mapping is not a specialized set, at least as far as typing is concerned: 
`isinstance({}, set)` is false. Semantically, they may be related, but the 
question here is whether the types are actually related.)

--

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