Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79535

Re: Truthiness

From random832@fastmail.us
Subject Re: Truthiness
Date 2014-10-23 11:24 -0400
References <61f0b04c-b827-4c03-b55d-4d5bd85b56f6@googlegroups.com> <074b949d-9999-42b9-9136-6e32d1cee922@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.15114.1414077886.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Oct 23, 2014, at 10:56, Simon Kennedy wrote:
> Thanks everyone. That's a thorough enough explanation for me.

You should know, though, that numeric values equal to 1 (and 0 for
False) _are_ == True. This works for dictionary keys, array indexes,
etc. The bool type is actually a subclass of int. Mathematical
operations on it will simply return an int, or float for division -
logical operations and bitwise and/or/xor return bool (bitwise not
returns an int because it returns the values -1 and -2)

So checking if something is == True is the same as checking if it's ==
1, and checking if it's == False is the same as checking if it's == 0.

Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Truthiness Simon Kennedy <sffjunkie@gmail.com> - 2014-10-23 07:30 -0700
  Re: Truthiness Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-23 08:45 -0600
    Re: Truthiness Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-24 11:42 +1100
  Re: Truthiness Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2014-10-23 16:47 +0200
    Re: Truthiness Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-10-23 17:01 +0200
    Re: Truthiness Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-23 16:07 +0000
  Re: Truthiness Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-10-23 16:49 +0200
  Re: Truthiness Skip Montanaro <skip.montanaro@gmail.com> - 2014-10-23 09:51 -0500
  Re: Truthiness Simon Kennedy <sffjunkie@gmail.com> - 2014-10-23 07:56 -0700
    Re: Truthiness random832@fastmail.us - 2014-10-23 11:24 -0400

csiph-web