[issue44989] Fix documentation for truth testing

2021-08-27 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I think that this proposal is either premature or not needed.  (But did you 
have anything specific in mind.)  As you indicated, there are two separate 
subissues here.

1. NotImplemented: Issue 35712 added "It should not be evaluated in a boolean 
context" to its entry in Library/constant.rst, followed by the notice of 
deprecation and intended removal. I don't think we should document the possible 
future change a second time elsewhere.

I agree that if and when NotImplemented becomes an exception and 
'bool(NotImplemented)' fails, then the exception should be added sentence you 
quoted.  But I think it possible that the warning will be left indefinitely 
(and think it should be) and would instead propose that the claim of future 
removal be removed.

2. 2nd and 3rd party invalidation:  I believe that several claims can be 
invalidated if one used special methods in ways not intended.  The all have the 
unwritten caveat 'as long as special methods are not abused'.  We have so far 
intentionally not added special mention of all such possible breakages.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue44989] Fix documentation for truth testing

2021-08-23 Thread Steven D'Aprano


New submission from Steven D'Aprano :

Truth testing states that "Any object can be tested for truth value" but from 
3.9 onwards, doing so with NotImplemented is deprecated and will be made a 
TypeError.

https://docs.python.org/3/library/stdtypes.html#truth-value-testing

It is also not true for third-party objects such as numpy arrays (which raise 
ValueError) and pandas dataframes.

I think that truth testing should have been considered a fundamental operation 
that (in the absence of bugs) always succeeds, but #35712 says different. Not 
that I'm bitter *wink*

In any case, at the very least the exception for NotImplemented should be 
documented.

--
assignee: docs@python
components: Documentation
messages: 400196
nosy: docs@python, steven.daprano
priority: normal
severity: normal
status: open
title: Fix documentation for truth testing
versions: Python 3.10, Python 3.11, Python 3.9

___
Python tracker 

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