Looks like NotImplemented is widely misunderstood. It should *ONLY* be returned from binary operator overloads, like __add__.
On Wed, Mar 11, 2020 at 03:49 <jdve...@gmail.com> wrote: > Steven D'Aprano wrote: > > On Wed, Mar 11, 2020 at 09:42:15AM -0000, Steve Jorgensen wrote: > > > I realize this is probably something that would be > > > hard to change for > > > compatibility reasons. Maybe someone can think of a way around that > > > though? > > > It seems to me that not NotImplemented should result in > > > NotImplemented and attempting to convert it to bool should raise > > > a > > > TypeError exception. > > > To my disappointment, you will get your wish, at least for the second > > part: > > https://bugs.python.org/issue35712 > > I am disappointed because, to me, it is a fundamental part of Python's > > object model that everything can be interpreted as a truthy/falsey > > object (in the absence of bugs). > > Anyway, the deprecation warning has been checked in, so it's probably > > only a matter of time before you will get your TypeError :-) > > > Oouh, I also feel disappointed. Indeed, I feel that NotImplemented is a > fiasco and that a TypeError exception should be raised instead. But I > suppose it is central to duck typing concept... > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/7VCQ6MZPC7MRX4FFPAG7X4AIAD7AP4SU/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido (mobile)
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/7UPOSQLEFWWWADPXXNMP42UN34VLMZAX/ Code of Conduct: http://python.org/psf/codeofconduct/