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


Groups > comp.lang.python > #44337

Re: epiphany

From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject Re: epiphany
Date 2013-04-25 09:15 -0400
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <roy-EB8571.09150125042013@news.panix.com> (permalink)
References (1 earlier) <5178884b$0$29977$c3e8da3$5496439d@news.astraweb.com> <mailman.1045.1366857991.3114.python-list@python.org> <5178b1db$0$29977$c3e8da3$5496439d@news.astraweb.com> <roy-649E1E.08363425042013@news.panix.com> <51792710$0$29977$c3e8da3$5496439d@news.astraweb.com>

Show all headers | View raw


In article <51792710$0$29977$c3e8da3$5496439d@news.astraweb.com>,
 Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote:

> > It also says, "Its truth value is true".  Why would they document that
> > fact if you weren't supposed to use it as a boolean operand?
> 
> You can use *anything* in Python in a boolean context. That's a language 
> feature: all objects are either truthy or falsey. As for why it is 
> documented for NotImplemented, I guess that's because some people might 
> guess that it is falsey, like None.

That was part of what added the epiphanality to the experience.  My 
first guess was exactly as you say, that bool(NotImplemented) would be 
false.  Once I discovered that it was true, the rest immediately fell 
into place and many lines of code got replaced by the simple:

    return all(r(...) for r in rules)
                  ^
                  |
                  +---- stuff that I'm not showing goes here :-)

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


Thread

epiphany Roy Smith <roy@panix.com> - 2013-04-24 19:50 -0400
  Re: epiphany Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-25 01:35 +0000
    Re: epiphany Roy Smith <roy@panix.com> - 2013-04-24 21:41 -0400
      Re: epiphany Chris Angelico <rosuav@gmail.com> - 2013-04-25 12:20 +1000
        Re: epiphany Roy Smith <roy@panix.com> - 2013-04-24 22:33 -0400
      Re: epiphany Ethan Furman <ethan@stoneleaf.us> - 2013-04-24 19:28 -0700
    Re: epiphany Ethan Furman <ethan@stoneleaf.us> - 2013-04-24 19:25 -0700
      Re: epiphany Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-25 04:32 +0000
        Re: epiphany Roy Smith <roy@panix.com> - 2013-04-25 08:36 -0400
          Re: epiphany Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-25 12:52 +0000
            Re: epiphany Roy Smith <roy@panix.com> - 2013-04-25 09:15 -0400
  Re: epiphany 88888 Dihedral <dihedral88888@googlemail.com> - 2013-04-28 14:14 -0700

csiph-web