Odd truth result with in and ==

Chris Angelico rosuav at gmail.com
Thu Nov 22 03:58:01 EST 2018


On Thu, Nov 22, 2018 at 7:51 PM Thomas Jollans <tjol at tjol.eu> wrote:
>
> On 21/11/2018 20:18, Python wrote:
> > $ python3
> > Python 3.5.2 (default, Nov 23 2017, 16:37:01)
> > [GCC 5.4.0 20160609] on linux
> > Type "help", "copyright", "credits" or "license" for more information.
> >>>> 1 in [1,2,3] == True
> > False
> >>>> 1 in ([1,2,3] == True)
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in <module>
> > TypeError: argument of type 'bool' is not iterable
> >>>> (1 in [1,2,3]) == True
> > True
> >
>
> See: https://github.com/cosmologicon/pywat ;-)
>

I find it fascinating that quite a few of the Wats given on the
landing page are specifically poking fun at IEEE floating point
(completely documented and intended behaviour that exists across many
languages), yet the "Wat Quiz", also in that repository, specifically
excludes floats. TRWTF is inconsistently poking fun at a language's
consistencies.

ChrisA



More information about the Python-list mailing list