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


Groups > comp.lang.python > #56530

Re: Python's and and Pythons or

References <91180c35-413f-4b65-a224-917d8d68b7ec@googlegroups.com> <5255f684$0$29984$c3e8da3$5496439d@news.astraweb.com>
Date 2013-10-10 12:13 +1100
Subject Re: Python's and and Pythons or
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.914.1381367643.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Oct 10, 2013 at 11:36 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> Other languages (Ruby, PHP, Javascript, etc.) also have
> truthy and falsey values, but in my opinion none of them have got it
> right. Python has a unifying model of truthiness: objects which represent
> "something" ought to be truthy, those which represent "nothing" ought to
> be falsey

Python's model makes a lot of sense. The only other system that I've
seen that makes as much sense is Pike's, which can be summarized as:

Falsey:
0 (the integer; does the job of None in many contexts)

Truthy:
Everything else.

Python lets you distinguish easily between an empty list and a list
with something in it; Pike lets you distinguish between a list and the
absence of a list.

The use of 'and' and 'or' in returning their arguments is an extremely
useful one, but I'm not sure it has a name. Pike and Lua have the same
behaviour; neither offers a good term for it. Recommendation: Invent a
term if you can't find one, and start using it. :)

ChrisA

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


Thread

Python's and  and Pythons or Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-09 16:54 -0700
  Re: Python's and  and Pythons or Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-10 00:36 +0000
    Re: Python's and and Pythons or Chris Angelico <rosuav@gmail.com> - 2013-10-10 12:13 +1100
  Re: Python's and  and Pythons or Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-09 23:12 -0700
    Re: Python's and and Pythons or Chris Angelico <rosuav@gmail.com> - 2013-10-10 17:45 +1100
    Re: Python's and  and Pythons or Ethan Furman <ethan@stoneleaf.us> - 2013-10-09 23:46 -0700
    Re: Python's and and Pythons or Terry Reedy <tjreedy@udel.edu> - 2013-10-10 03:43 -0400
    Re: Python's and and Pythons or Chris Angelico <rosuav@gmail.com> - 2013-10-10 19:03 +1100
    Re: Python's and and Pythons or Ethan Furman <ethan@stoneleaf.us> - 2013-10-10 06:33 -0700
    Re: Python's and and Pythons or Terry Reedy <tjreedy@udel.edu> - 2013-10-10 21:41 -0400
    Re: Python's and and Pythons or Ethan Furman <ethan@stoneleaf.us> - 2013-10-10 19:47 -0700
  Re: Python's and  and Pythons or Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-09 23:55 -0700

csiph-web