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


Groups > comp.lang.python > #5449

Re: checking if a list is empty

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'value,': 0.04; 'way:': 0.05; 'python?': 0.07; 'sadly': 0.07; 'terry': 0.07; 'python': 0.07; '(there': 0.09; 'alter': 0.09; 'arithmetic': 0.09; 'bool': 0.09; 'brilliant': 0.09; 'contexts': 0.09; 'definitions.': 0.09; 'indicates': 0.09; 'properties,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'url:%28': 0.09; 'url:%29': 0.09; 'pm,': 0.11; 'am,': 0.14; 'say,': 0.14; 'wrote:': 0.14; 'defined': 0.15; 'arithmetic.': 0.16; 'boolean': 0.16; 'equality': 0.16; 'evaluates': 0.16; 'expression:': 0.16; 'first-class': 0.16; 'fruit.': 0.16; 'leibniz': 0.16; 'mod': 0.16; 'ordinals': 0.16; 'properties.': 0.16; 'reedy': 0.16; 'sense:': 0.16; 'thinking.': 0.16; 'writings': 0.16; 'mathematics': 0.16; 'math': 0.16; 'phrase': 0.19; 'discussion': 0.20; 'language': 0.20; 'seems': 0.21; 'jan': 0.22; 'saying': 0.22; 'subject:list': 0.22; 'header :In-Reply-To:1': 0.22; 'fail': 0.22; 'values': 0.23; '(who': 0.23; 'fundamental': 0.23; 'numbers.': 0.23; 'objects': 0.24; 'url:wiki': 0.24; 'example': 0.24; 'field,': 0.25; 'possible,': 0.25; 'value.': 0.25; 'says': 0.25; 'define': 0.26; 'statement': 0.26; "i'm": 0.26; 'classes': 0.26; '(in': 0.27; 'object': 0.27; 'url:edu': 0.28; 'definition': 0.29; 'mode': 0.29; 'class': 0.29; 'class.': 0.29; 'consistently': 0.29; 'order.': 0.29; 'least': 0.30; 'seem': 0.30; 'this.': 0.30; '"in': 0.31; 'clock': 0.31; 'if,': 0.31; 'logic': 0.31; 'seemingly': 0.31; 'sometimes.': 0.31; 'spelling': 0.31; 'vast': 0.31; 'second': 0.31; 'does': 0.31; 'equal': 0.31; 'language.': 0.31; "skip:' 10": 0.32; 'to:addr :python-list': 0.32; 'another': 0.32; 'done': 0.32; 'usual': 0.32; 'generally': 0.33; 'sometimes': 0.33; 'header:X-Complaints-To:1': 0.34; 'actually': 0.34; 'summary': 0.35; 'characters': 0.35; 'kids': 0.35; 'url:en': 0.35; 'header:User-Agent:1': 0.35; 'point': 0.35; 'ordered': 0.35; 'allow': 0.36; '(with': 0.36; 'missing': 0.36; 'properties': 0.36; 'think': 0.36; 'some': 0.37; 'should': 0.37; 'identity': 0.38; 'steven': 0.38; 'but': 0.38; 'happens': 0.38; 'pretty': 0.38; 'url:google': 0.38; 'members': 0.38; 'url:org': 0.38; 'third': 0.38; 'used': 0.38; 'received:org': 0.38; 'majority': 0.39; 'further': 0.62; 'addition': 0.62; 'our': 0.63; 'law': 0.64; 'entities': 0.65; 'believe': 0.66; 'url:%1': 0.67; 'refuse': 0.68; 'url:sa': 0.68; 'afraid': 0.69; 'url:http': 0.71; 'url:url': 0.84; "'true'": 0.84; 'child,': 0.84; 'conformable': 0.84; 'discovering': 0.84; 'examination': 0.84; 'heaven': 0.84; 'preclude': 0.84; 'believing': 0.91; 'defend': 0.91; 'recognition': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: checking if a list is empty
Date Sun, 15 May 2011 17:36:01 -0400
References <mailman.1226.1304663814.9059.python-list@python.org> <200e93c2-6b87-4113-9c6f-85815e51ea77@28g2000yqu.googlegroups.com> <4dc4b3c5$0$29991$c3e8da3$5496439d@news.astraweb.com> <iuvp98-446.ln1@svn.schaathun.net> <roy-5F8DA7.08265211052011@news.panix.com> <931adaF9g1U1@mid.individual.net> <roy-FC7816.07362712052011@news.panix.com> <4dcc785e$0$29980$c3e8da3$5496439d@news.astraweb.com> <d423a455-f14e-4cb4-8744-0a49259c9c86@34g2000pru.googlegroups.com> <4dce31b3$0$29980$c3e8da3$5496439d@news.astraweb.com> <d72b37d6-bf1e-4cec-94e3-88baca894fd9@35g2000prp.googlegroups.com> <mailman.1548.1305380575.9059.python-list@python.org> <a86edee8-306b-4777-99fb-99895b512ef6@k15g2000pri.googlegroups.com> <87wrhshni4.fsf@benfinney.id.au> <61ccd16d-02c1-4adb-adc3-26a876a8762f@z15g2000prn.googlegroups.com> <4dcf5f99$0$29996$c3e8da3$5496439d@news.astraweb.com> <48487954-dea9-483f-aaf2-de71e21b0f98@18g2000prd.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host rain.gmane.org
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10
In-Reply-To <48487954-dea9-483f-aaf2-de71e21b0f98@18g2000prd.googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1603.1305495372.9059.python-list@python.org> (permalink)
Lines 115
NNTP-Posting-Host 82.94.164.166
X-Trace 1305495373 news.xs4all.nl 41102 [::ffff:82.94.164.166]:54859
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:5449

Show key headers only | View raw


On 5/15/2011 1:33 PM, rusi wrote:
> On May 15, 10:07 am, Steven D'Aprano<steve
> +comp.lang.pyt...@pearwood.info>  wrote:
>>
>> I'm afraid I don't understand what you mean. Can you explain please, what
>> properties of "first class booleans" do you think are missing from Python?

Given the usual CS definition of 'first class object', all Python 
objects are first class. But that does not preclude other definitions.

> Dijkstra's writings I alluded to, take a logic/math line to this.  Let
> me try to rephrase Dijkstra (who is now sadly not able to defend our
> (mis)understandings of his writings) in a more linguistic way:
>
> In English when we say something like "x is y"  the y (predicate) can
> be an adjective phrase -- the apple is red -- or a noun phrase -- the
> apple is a fruit.
>
> They seem similar; they are very different -- you agree??

Sometimes. Sometimes it could mean 'the apple is fruity' or 'the apple 
has the characters that define the wider grouping of fruits'. "John is 
brilliant", "John is a brilliant man", and "John is a genius" (there is 
no 'a brilliant') pretty much have the same effective meaning. But I get 
the point about reification.

>> From times immemorial 'true' and 'false' have been used in the
> adjective sense: eg Such-and-such statement is true.
> Boole's contribution -- actually Dijkstra's recognition of Boole's
> contribution -- is that dignifying {true, false} from adjectives to
> nouns -- the boolean domain -- fundamentally alter and improve the
> rules and possibilities for our thinking. [See his puzzles in the same
> paper:
> http://www.google.com/url?sa=D&q=http://www.cs.utexas.edu/users/EWD/transcriptions/EWD10xx/EWD1070.html
>
> As an analogy for this consider arithmetic.
>
> Even primitive people can count: My 3 children, my 5 sheep.  They do
> this with the ordinals -- first child, second child, third child...
> But arithmetic cannot really take off until we allow these numbers
> (ordinals) to be dignified into entities in their own right --
> cardinals.
> ie the mathematician needs to believe in the existence of the numbers
> 1,2 etc for him to do his job well.
>
> [As an aside I may mention that philosophers of mathematicians will
> call this platonism: "In which heaven do these numbers exist?"
> And platonism is mysticism. And mysticism is bullshit.  But the vast
> majority of practicing mathematicians refuse to be dislodged from
> their 'platonic heaven.'  For them mathematics can only be done if it
> is done in 'discovery' mode and not in 'invention' mode.]
>
> And so just as good math happens by believing that the numbers exist
> and discovering their properties, good logic happens when we believe
> that {True, False} exist (in some platonic heaven). Which is to say
> they should be nouns in our language.
>
> Well that in summary is the Boole's ideology (Dijkstra's evangelism)
> understood linguistically and independent of python/programming.
>
> Reapplied back to the math/programming field, we find that if a value-
> domain (data-type) has to be first-class, it at the least has to be a
> denotable entity in the language which should be conformable with its
> abstract/expected properties.
> For example if my language seems to have entities like '2' '3' '+' but
> 2+3 does not work out equal to 5 we would (I hope!) not say the
> language has first-class numbers.

You seem to equate 'number' with 'natural number' in the classical 
sense. If '2' and '3' are residue classes (remainers) mod 5, then 2 + 3 
is 0. Even kids understand clock arithmetics. Of course,
the 24 hour (0 to 23 hourse) is saner than the older 1-12,am/pm system,
but kids even manage with that.

> But in order for any of this discussion to be possible, equality
> should be well-defined.
> Which means that in addition to being an equivalence relation it must
> have substitutivity
> http://en.wikipedia.org/wiki/Equality_%28mathematics%29#Some_basic_logical_properties_of_equality
> which is another form of a very fundamental principle attributed to
> Leibniz, the principle of identity of indiscernibles:
> http://en.wikipedia.org/wiki/Leibniz%27s_law
>
> Seemingly you and Dijkstra are saying something similar when you say
> [1,2,3] is a way of writing true
> and he says 2<3 is a way of writing true.
> But on further examination (with Leibniz law above) Dijkstra's 2<3 =
> True will work consistently in all contexts

In general, a < b will work consistently as generally expected of total 
orders if, but only if, a and b are members of a totally ordered set and 
< indicates that total order. If '<' represents a partial order, 'a<b' 
may be undefined or defined as false when 'b<a' is also false.

 > but [1,2,3] = True will work sometimes and fail sometimes.

'Bool(<normal expression*>) is a much a spelling of true or false as 'a 
< b'. It works just as consistently in all contexts.

*nornal expression: evaluates to an object with a well-defined boolean 
value, which is to say, causes bool() to return True or False.

> In mathSpeak we say, the definition of bool is not well defined

The math definition of bool or the Python definition?
And what definition of 'well-defined'? On builtins, bool(ob) always 
returns the same value. And the values are pretty consistent.

> In CSSpeak we say the definition is not first class.

What CS definition?

-- 
Terry Jan Reedy

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


Thread

checking if a list is empty Jabba Laci <jabba.laci@gmail.com> - 2011-05-06 02:36 -0400
  Re: checking if a list is empty Richard Thomas <chardster@gmail.com> - 2011-05-06 03:34 -0700
  Re: checking if a list is empty scattered <tooscattered@gmail.com> - 2011-05-06 14:57 -0700
    Re: checking if a list is empty Philip Semanchuk <philip@semanchuk.com> - 2011-05-06 18:21 -0400
    Re: checking if a list is empty Ian Kelly <ian.g.kelly@gmail.com> - 2011-05-06 17:51 -0600
      Re: checking if a list is empty Jon Clements <joncle@googlemail.com> - 2011-05-06 17:43 -0700
        Re: checking if a list is empty Hans Mulder <hansmu@xs4all.nl> - 2011-05-14 10:52 +0200
    Re: checking if a list is empty Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-07 02:51 +0000
      Re: checking if a list is empty Hans Georg Schaathun <hg@schaathun.net> - 2011-05-11 10:02 +0100
        Re: checking if a list is empty Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-11 12:14 +0000
          Re: checking if a list is empty Hans Georg Schaathun <hg@schaathun.net> - 2011-05-11 15:05 +0100
            Re: checking if a list is empty "D'Arcy J.M. Cain" <darcy@druid.net> - 2011-05-11 10:27 -0400
              Re: checking if a list is empty Hans Georg Schaathun <hg@schaathun.net> - 2011-05-11 18:59 +0100
                Re: checking if a list is empty alex23 <wuwei23@gmail.com> - 2011-05-11 20:16 -0700
                Re: checking if a list is empty Hans Georg Schaathun <hg@schaathun.net> - 2011-05-12 06:20 +0100
            Re: checking if a list is empty Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-11 15:50 +0000
              Re: checking if a list is empty Chris Angelico <rosuav@gmail.com> - 2011-05-12 02:05 +1000
                Re: checking if a list is empty Hans Georg Schaathun <hg@schaathun.net> - 2011-05-11 18:56 +0100
                Re: checking if a list is empty harrismh777 <harrismh777@charter.net> - 2011-05-11 16:13 -0500
          RE: checking if a list is empty "Prasad, Ramit" <ramit.prasad@jpmchase.com> - 2011-05-11 13:39 -0400
        Re: checking if a list is empty Roy Smith <roy@panix.com> - 2011-05-11 08:26 -0400
          Re: checking if a list is empty Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-11 13:29 +0000
          Re: checking if a list is empty Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-05-12 17:44 +1200
            Re: checking if a list is empty Hans Georg Schaathun <hg@schaathun.net> - 2011-05-12 07:06 +0100
            Re: checking if a list is empty Roy Smith <roy@panix.com> - 2011-05-12 07:36 -0400
              Re: checking if a list is empty Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-13 00:16 +0000
                Re: checking if a list is empty rusi <rustompmody@gmail.com> - 2011-05-12 23:46 -0700
                Re: checking if a list is empty Chris Rebert <clp2@rebertia.com> - 2011-05-13 01:02 -0700
                Re: checking if a list is empty rusi <rustompmody@gmail.com> - 2011-05-13 03:58 -0700
                Re: checking if a list is empty Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-05-14 14:34 +1200
                Re: checking if a list is empty David Robinow <drobinow@gmail.com> - 2011-05-14 10:28 -0400
                Re: checking if a list is empty Roy Smith <roy@panix.com> - 2011-05-14 11:04 -0400
                Re: checking if a list is empty Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-14 07:39 +0000
                Re: checking if a list is empty rusi <rustompmody@gmail.com> - 2011-05-14 00:45 -0700
                Re: checking if a list is empty Chris Angelico <rosuav@gmail.com> - 2011-05-14 23:42 +1000
                Re: checking if a list is empty rusi <rustompmody@gmail.com> - 2011-05-14 08:47 -0700
                Re: checking if a list is empty Chris Angelico <rosuav@gmail.com> - 2011-05-15 01:55 +1000
                Re: checking if a list is empty rusi <rustompmody@gmail.com> - 2011-05-14 10:43 -0700
                Re: checking if a list is empty Terry Reedy <tjreedy@udel.edu> - 2011-05-14 17:29 -0400
                Re: checking if a list is empty Ben Finney <ben+python@benfinney.id.au> - 2011-05-15 09:26 +1000
                Re: checking if a list is empty rusi <rustompmody@gmail.com> - 2011-05-14 19:41 -0700
                Re: checking if a list is empty Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-15 05:07 +0000
                Re: checking if a list is empty rusi <rustompmody@gmail.com> - 2011-05-15 10:33 -0700
                Re: checking if a list is empty Terry Reedy <tjreedy@udel.edu> - 2011-05-15 17:36 -0400
                Re: checking if a list is empty rusi <rustompmody@gmail.com> - 2011-05-15 22:56 -0700
                Re: checking if a list is empty Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-16 00:36 +0000
                Re: checking if a list is empty harrismh777 <harrismh777@charter.net> - 2011-05-15 20:59 -0500
                Re: checking if a list is empty rusi <rustompmody@gmail.com> - 2011-05-15 22:40 -0700
                Re: checking if a list is empty harrismh777 <harrismh777@charter.net> - 2011-05-15 20:25 -0500
                Re: checking if a list is empty Terry Reedy <tjreedy@udel.edu> - 2011-05-15 21:57 -0400
                Re: checking if a list is empty Terry Reedy <tjreedy@udel.edu> - 2011-05-14 16:59 -0400
                Re: checking if a list is empty Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-15 05:00 +0000
                Re: checking if a list is empty Terry Reedy <tjreedy@udel.edu> - 2011-05-14 16:53 -0400
          Re: checking if a list is empty Terry Reedy <tjreedy@udel.edu> - 2011-05-12 15:37 -0400
          Re: checking if a list is empty Terry Reedy <tjreedy@udel.edu> - 2011-05-12 18:00 -0400
  Re: checking if a list is empty Raymond Hettinger <python@rcn.com> - 2011-05-06 15:52 -0700

csiph-web