Re: checking if a list is empty

2011-05-22 Thread Thomas Rachel
Am 11.05.2011 23:02 schrieb Ian: On 11/05/2011 20:13, Hans Georg Schaathun wrote: Lists do not have truth values in the application domain, and therefore truth values in the implementation domain is complicated. Exactly. Its just a convention. If it exists, its true, if if doesn't its false.

Re: checking if a list is empty

2011-05-22 Thread Ian
On 12/05/2011 04:51, Chris Angelico wrote: On Thu, May 12, 2011 at 7:02 AM, Ian wrote: In the "real world" lists of zero items do not exist. You don't go shopping with a shopping list of zero items. Actually, yes you do. You maintain your shopping list between trips; whenever you need somethi

Re: checking if a list is empty

2011-05-21 Thread Chris Angelico
On Sun, May 22, 2011 at 2:32 PM, rusi wrote: > Recently on the emacs list there was a big flame-fest because the > behavior (aka interface) of return/newline changed. > The argument for change: Can we have emacs behave a little more like a > 21st century application? > Against: Somebody's scriptin

Re: checking if a list is empty

2011-05-21 Thread rusi
On May 22, 8:52 am, Chris Angelico wrote: > On Sun, May 22, 2011 at 1:02 PM, rusi wrote: > > Why is the C library in linux called libc6 and not just libc? > > I assume you mean this?http://www.linux-m68k.org/faq/glibcinfo.html Ha Ha! Thanks for that link! I quote: > You should not be using libc

Re: checking if a list is empty

2011-05-21 Thread Chris Angelico
On Sun, May 22, 2011 at 1:02 PM, rusi wrote: > Why is the C library in linux called libc6 and not just libc? I assume you mean this? http://www.linux-m68k.org/faq/glibcinfo.html When you dynamically link against a shared object, you save on executable size, but you have to have that shared objec

Re: checking if a list is empty

2011-05-21 Thread rusi
On May 22, 1:11 am, Terry Reedy wrote: > I agree that the domain of a function should be defined from the start > (and only expanded in the future). I dont understand... I dont always write correct code -- otherwise called 'a bug' -- though I never let the damn bug lose intentionally. And when I

Re: checking if a list is empty

2011-05-21 Thread Chris Angelico
On Sun, May 22, 2011 at 11:02 AM, Steven D'Aprano wrote: > On Sat, 21 May 2011 15:46:01 +0100, John J Lee wrote: > > Er, yes? But in any realistic example (your trivial function xyzzyx below > is not very realistic) you'll almost certainly get additional hints in > the function body. True, but so

Re: checking if a list is empty

2011-05-21 Thread Steven D'Aprano
On Sat, 21 May 2011 15:46:01 +0100, John J Lee wrote: > In the absence of an explicit interface declaration (have any standards > emerged for that in Python 3, BTW?), the use of len() does give you some > information about the interface, which sometimes makes it easier to > change the function. E

Re: checking if a list is empty

2011-05-21 Thread Terry Reedy
On 5/21/2011 10:46 AM, John J Lee wrote: In the absence of an explicit interface declaration (have any standards emerged for that in Python 3, BTW?), the use of len() does give you some information about the interface, which sometimes makes it easier to change the function. I'm sure you fully u

Re: checking if a list is empty

2011-05-21 Thread Emile van Sebille
On 5/21/2011 7:46 AM John J Lee said... Gregory Ewing writes: Hans Georg Schaathun wrote: 0 is a number as real and existent as any other, one would think that the empty list is also as real and existent as any other list. 0 does have some special properties, though, such as being the add

Re: checking if a list is empty

2011-05-21 Thread John J Lee
Gregory Ewing writes: > Hans Georg Schaathun wrote: >> 0 is a number as real and existent as any other, >> one would think that the empty list is also as real and existent as >> any other list. > > 0 does have some special properties, though, such as > being the additive identity and not having

Re: checking if a list is empty

2011-05-15 Thread rusi
On May 16, 2:36 am, Terry Reedy wrote: > On 5/15/2011 1:33 PM, rusi wrote: > > > On May 15, 10:07 am, Steven D'Aprano > +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 a

Re: checking if a list is empty

2011-05-15 Thread rusi
I have been scolded off-list for pursuing a discussion that has nothing to do with python. So I continue a bit gingerly :-) and will stop when others feel this is useless/irrelevant/whatever. Steven wrote: > I'm afraid I didn't find your discussion about reification, Platonism and > linguistics

Re: checking if a list is empty

2011-05-15 Thread Algis Kabaila
On Friday 13 May 2011 18:47:50 Hans Georg Schaathun wrote: > On Thu, 12 May 2011 23:20:20 +1000, Chris Angelico > >wrote: > : Writing a program requires expertise both in programming snip... > > And the main difference here, is that the civil engineers > have a much better language to share

Re: checking if a list is empty

2011-05-15 Thread harrismh777
Steven D'Aprano wrote: I'm afraid I don't understand what you mean. Can you explain please, http://www.informatik.uni-bremen.de/agbkb/lehre/ws06-07/casl/slides/Datatypes-II.pdf Geeze, I wonder if software is mathematics kind regards, m harris -- http://mail.python.org/mailman/li

Re: checking if a list is empty

2011-05-15 Thread Terry Reedy
On 5/15/2011 5:36 PM, Terry Reedy wrote: On 5/15/2011 1:33 PM, rusi wrote: Dijkstra's writings I alluded to, at http://www.cs.utexas.edu/users/EWD/transcriptions/EWD10xx/EWD1070.html "Acquiring that familiarity requires what in these financial times is known as "intellectual investment"; y

Re: checking if a list is empty

2011-05-15 Thread harrismh777
rusi wrote: But on further examination (with Leibniz law above) Dijkstra's 2<3 = True will work consistently in all contexts but [1,2,3] = True will work sometimes and fail sometimes. It would have to be written 2<3 == True; [1,2,3] == True; otherwise, ... +1 QOTW -- http://mail.python.org/

Re: checking if a list is empty

2011-05-15 Thread Steven D'Aprano
On Sun, 15 May 2011 10:33:38 -0700, rusi wrote: > On May 15, 10:07 am, Steven D'Aprano +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? [snip]

Re: checking if a list is empty

2011-05-15 Thread Terry Reedy
On 5/15/2011 1:33 PM, rusi wrote: On May 15, 10:07 am, Steven D'Aprano 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

Re: checking if a list is empty

2011-05-15 Thread rusi
On May 15, 10:07 am, Steven D'Aprano 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? Dijkstra's writings I alluded to, take a logic/math line to this. Let me try to rephrase Dijkstr

Re: checking if a list is empty

2011-05-14 Thread Steven D'Aprano
On Sat, 14 May 2011 19:41:32 -0700, rusi wrote: > The python entities: {True, False} are not an exact (isomorphic) model > for the semantic boolean domain {true, false} (which is needed for > example to explicate the semantics of if while etc) Which is to say the > boolean type in python is not f

Re: checking if a list is empty

2011-05-14 Thread Steven D'Aprano
On Sat, 14 May 2011 00:45:29 -0700, rusi wrote: > On May 14, 12:39 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> On Thu, 12 May 2011 23:46:12 -0700, rusi wrote: >> > Mathematics has existed for millenia. Hindu-arabic numerals (base-10 >> > numbers) have been known for about one m

Re: checking if a list is empty

2011-05-14 Thread rusi
On May 15, 4:26 am, Ben Finney wrote: > rusi writes: > > [Steven quote] > > In Python, [1, 2, 3] is another way of writing true, and [] is another > > way of writing false. Similarly with any other arbitrary objects. The > > only things that bools True and False are good for are: > > > > [end St

Re: checking if a list is empty

2011-05-14 Thread Ben Finney
rusi writes: > [Steven quote] > In Python, [1, 2, 3] is another way of writing true, and [] is another > way of writing false. Similarly with any other arbitrary objects. The > only things that bools True and False are good for are: > > [end Steven quote] > > > So since

Re: checking if a list is empty

2011-05-14 Thread Terry Reedy
On 5/14/2011 1:43 PM, rusi wrote: But it seems you did not get the moral? Spelt out: "Beware of lossy compression!" [Which is also the moral of my 'proof'] I get it now. As I suggested in response to Stephen, [] and [1] spell False and True only in boolean contexts (if/while headers) where th

Re: checking if a list is empty

2011-05-14 Thread Terry Reedy
On 5/14/2011 3:45 AM, rusi wrote: (True = True) is False is a syntax error ;-) and 'True = True' is a (useless) statement, and statements do not have boolean values, and 'True == True' *is* True, which is to say, ((True == True) is False) is False. -- Terry Jan Reedy -- http://mail.python.o

Re: checking if a list is empty

2011-05-14 Thread Terry Reedy
On 5/14/2011 3:39 AM, Steven D'Aprano wrote: Th money-quote as regards using arbitrary objects in truth tests: [quote] All this changed with the introduction of the two-element boolean domain {true, false} which provides the vocabulary needed to assign values to boolean expr

Re: checking if a list is empty

2011-05-14 Thread rusi
On May 14, 8:55 pm, Chris Angelico wrote: > On Sun, May 15, 2011 at 1:47 AM, rusi wrote: > > So since > > [1,2,3] is one way of writing True (lets call it True3) > > and [1,2] is another (call it True2) > > then we have True3 == True2 is False > > > But since according to Steven (according to Pyt

Re: checking if a list is empty

2011-05-14 Thread Chris Angelico
On Sun, May 15, 2011 at 1:47 AM, rusi wrote: > So since > [1,2,3] is one way of writing True (lets call it True3) > and [1,2] is another (call it True2) > then we have True3 == True2 is False > > But since according to Steven (according to Python?) True3 *is the > same* as True2 > we get >  False

Re: checking if a list is empty

2011-05-14 Thread rusi
On May 14, 6:42 pm, Chris Angelico wrote: > On Sat, May 14, 2011 at 5:45 PM, rusi wrote: > > And then we get the interesting result that > > (True = True) is False > > How does this work? In Python, the = sign is illegal there, and if you > mean True == True, then it's True (obviously), which is

Re: checking if a list is empty

2011-05-14 Thread Roy Smith
In article , David Robinow wrote: > On Fri, May 13, 2011 at 10:34 PM, Gregory Ewing > wrote: > > rusi wrote: > > > >> Dijkstra's problem (paraphrased) is that python, by choosing the > >> FORTRAN alternative of having a non-first-class boolean type, hinders > >> scientific/mathematical thinking

Re: checking if a list is empty

2011-05-14 Thread David Robinow
On Fri, May 13, 2011 at 10:34 PM, Gregory Ewing wrote: > rusi wrote: > >> Dijkstra's problem (paraphrased) is that python, by choosing the >> FORTRAN alternative of having a non-first-class boolean type, hinders >> scientific/mathematical thinking/progress. > > Python doesn't have the flaw that Di

Re: checking if a list is empty

2011-05-14 Thread Chris Angelico
On Sat, May 14, 2011 at 5:45 PM, rusi wrote: > And then we get the interesting result that > (True = True) is False How does this work? In Python, the = sign is illegal there, and if you mean True == True, then it's True (obviously), which is not False. Chris Angelico -- http://mail.python.org/

Re: checking if a list is empty

2011-05-14 Thread Hans Mulder
On 07/05/2011 02:43, Jon Clements wrote: On May 7, 12:51 am, Ian Kelly wrote: On Fri, May 6, 2011 at 4:21 PM, Philip Semanchuk wrote: What if it's not a list but a tuple or a numpy array? Often I just want to iterate through an element's items and I don't care if it's a list, set, etc. For

Re: checking if a list is empty

2011-05-14 Thread rusi
On May 14, 12:39 pm, Steven D'Aprano wrote: > On Thu, 12 May 2011 23:46:12 -0700, rusi wrote: > > Mathematics has existed for millenia. Hindu-arabic numerals (base-10 > > numbers) have been known for about one millennium > > The boolean domain is only a 100 years old. Unsurprisingly it is not > >

Re: checking if a list is empty

2011-05-14 Thread Steven D'Aprano
On Thu, 12 May 2011 23:46:12 -0700, rusi wrote: > Mathematics has existed for millenia. Hindu-arabic numerals (base-10 > numbers) have been known for about one millennium > The boolean domain is only a 100 years old. Unsurprisingly it is not > quite 'first-class' yet: See > http://www.cs.utexas.ed

Re: checking if a list is empty

2011-05-13 Thread Ian Kelly
On Fri, May 13, 2011 at 10:47 PM, harrismh777 wrote: > http://www.inf.ed.ac.uk/teaching/courses/inf1/fp/ > > http://www.cs.ou.edu/~rlpage/fpclassSpring97/ > > > There are lots of these...   the two above afaik are still doing this at the > entry level...    ... supposedly, these kids are 'mostly'

Re: checking if a list is empty

2011-05-13 Thread harrismh777
Ian Kelly wrote: >> Well, at least Haskell is probably better as an introductory language >> than Lisp or Scheme. But what schools actually do this? http://www.inf.ed.ac.uk/teaching/courses/inf1/fp/ http://www.cs.ou.edu/~rlpage/fpclassSpring97/ There are lots of these... the two above

Re: checking if a list is empty

2011-05-13 Thread Gregory Ewing
rusi wrote: Dijkstra's problem (paraphrased) is that python, by choosing the FORTRAN alternative of having a non-first-class boolean type, hinders scientific/mathematical thinking/progress. Python doesn't have the flaw that Dijkstra was talking about. Fortran's flaw wasn't so much the lack of

Re: checking if a list is empty

2011-05-13 Thread Gregory Ewing
harrismh777 wrote: ... and I'm also lumping two other languages into this 'category'... namely, Scheme, and Erlang. Scheme isn't really a functional language, though. You can use a subset of it in a functional way, but it doesn't have the sort of built-in support for pattern matching and cas

Re: checking if a list is empty

2011-05-13 Thread Gregory Ewing
Ian Kelly wrote: If a math major comes to you wanting to learn some programming for theorem-proving, bearing in mind that they probably aren't interested in learning more than a single language, I would question whether theorem-proving is the *only* thing they will ever want to do with a progra

Re: checking if a list is empty

2011-05-13 Thread Ian Kelly
On Fri, May 13, 2011 at 6:48 PM, harrismh777 wrote: > Ian Kelly wrote: >> >> Well, at least Haskell is probably better as an introductory language >> than Lisp or Scheme.  But what schools actually do this? > > http://www.cs.kent.ac.uk/teaching/resources/haskell/HugsResources.html > http://researc

Re: checking if a list is empty

2011-05-13 Thread harrismh777
Ian Kelly wrote: Well, at least Haskell is probably better as an introductory language than Lisp or Scheme. But what schools actually do this? http://www.cs.kent.ac.uk/teaching/resources/haskell/HugsResources.html http://research.cs.queensu.ca/home/cisc260/2010w/haskell.html These are just

Re: checking if a list is empty

2011-05-13 Thread Ian Kelly
On Fri, May 13, 2011 at 1:41 PM, harrismh777 wrote: > On the other hand, kids today are dumped into a first comp sci course in > programming and plopped in-front of a Hugs interactive shell and then are > expected to learn programming and be successful by trying to grasp pure > functional programm

Re: checking if a list is empty

2011-05-13 Thread harrismh777
ru...@yahoo.com wrote: http://www.codinghorror.com/blog/2006/07/separating-programming-sheep-from-non-programming-goats.html A later paper by the same authors... (http://www.eis.mdx.ac.uk/research/PhDArea/saeed/paper3.pdf) These papers are fascinating reading, not only for philosophy sake i

Re: checking if a list is empty

2011-05-13 Thread rusi
On May 13, 1:02 pm, Chris Rebert wrote: > On Thu, May 12, 2011 at 11:46 PM, rusi wrote: > > > The boolean domain is only a 100 years old. > > Unsurprisingly it is not quite 'first-class' yet: See > > It is nowadays. Every halfway-mainstream language I can think of has > an explicit boolean dataty

Re: checking if a list is empty

2011-05-13 Thread Hans Georg Schaathun
On Thu, 12 May 2011 23:20:20 +1000, Chris Angelico wrote: : Writing a program requires expertise both in programming and in the : purpose for which it's being written. Ultimately, a programmer is a : translator; without proper comprehension of the material he's : translating, he can't make a

Re: checking if a list is empty

2011-05-13 Thread Chris Rebert
On Thu, May 12, 2011 at 11:46 PM, rusi wrote: > The boolean domain is only a 100 years old. > Unsurprisingly it is not quite 'first-class' yet: See It is nowadays. Every halfway-mainstream language I can think of has an explicit boolean datatype. Heck, as of C99, even C has one now. I conjecture

Re: checking if a list is empty

2011-05-12 Thread rusi
Mathematics has existed for millenia. Hindu-arabic numerals (base-10 numbers) have been known for about one millennium The boolean domain is only a 100 years old. Unsurprisingly it is not quite 'first-class' yet: See http://www.cs.utexas.edu/users/EWD/transcriptions/EWD10xx/EWD1070.html [Lifted fro

Re: checking if a list is empty

2011-05-12 Thread Steven D'Aprano
On Thu, 12 May 2011 07:36:27 -0400, Roy Smith wrote: > In article <931adaf9g...@mid.individual.net>, > Gregory Ewing wrote: > >> Roy Smith wrote: >> >>If both are numbers, they are converted to a common type. Otherwise, >> >>objects of different types always compare unequal >> >> That's just t

Re: checking if a list is empty

2011-05-12 Thread Terry Reedy
On 5/12/2011 3:37 PM, Terry Reedy wrote: On 5/11/2011 8:26 AM, Roy Smith wrote: I conclude that li == [] should have returned False. Either I'm not understanding things correctly, or this is a bug. The doc is wrong (and not only on this). I am working on a report with suggested fixes. Will po

Re: checking if a list is empty

2011-05-12 Thread Terry Reedy
On 5/11/2011 8:26 AM, Roy Smith wrote: I conclude that li == [] should have returned False. Either I'm not understanding things correctly, or this is a bug. The doc is wrong (and not only on this). I am working on a report with suggested fixes. Will post number when finish. -- Terry Jan Re

Re: checking if a list is empty

2011-05-12 Thread ru...@yahoo.com
On 05/12/2011 12:13 AM, Steven D'Aprano wrote: >[snip] > http://www.codinghorror.com/blog/2006/07/separating-programming-sheep-from-non-programming-goats.html > > Shorter version: it seems that programming aptitude is a bimodal > distribution, with very little migration from the "can't program" hum

Re: checking if a list is empty

2011-05-12 Thread Chris Angelico
On Fri, May 13, 2011 at 12:02 AM, Ethan Furman wrote: > Chris Angelico wrote: >> >> On Thu, May 12, 2011 at 7:02 AM, Ian wrote: >>> >>> In the "real world"  lists of zero items do not exist. >>> You don't go shopping with a shopping list of zero items. >> >> Actually, yes you do. You maintain you

Re: checking if a list is empty

2011-05-12 Thread Ethan Furman
Chris Angelico wrote: On Thu, May 12, 2011 at 7:02 AM, Ian wrote: In the "real world" lists of zero items do not exist. You don't go shopping with a shopping list of zero items. Actually, yes you do. You maintain your shopping list between trips; whenever you need something, you put it on th

Re: checking if a list is empty

2011-05-12 Thread Chris Angelico
On Thu, May 12, 2011 at 10:43 PM, Hans Georg Schaathun wrote: > On Thu, 12 May 2011 22:16:10 +1000, Chris Angelico >   wrote: > :  Anyone can join. Not everyone wants to join. Me, I'm happy here as a > :  priest of the software industry, and I have no desire to become a > :  priest of, say, autom

Re: checking if a list is empty

2011-05-12 Thread Hans Georg Schaathun
On Thu, 12 May 2011 22:16:10 +1000, Chris Angelico wrote: : Anyone can join. Not everyone wants to join. Me, I'm happy here as a : priest of the software industry, and I have no desire to become a : priest of, say, automotive engineering or concrete pouring. Would an : expert concreter be ex

Re: checking if a list is empty

2011-05-12 Thread Chris Angelico
On Thu, May 12, 2011 at 4:21 PM, Hans Georg Schaathun wrote: > On Thu, 12 May 2011 01:49:05 -0400, D'Arcy J.M. Cain >   wrote: > :  That's not programming.  That's using a canned app that a programmer > :  wrote that takes your unstructured input and does something useful with > :  it.  Spreadshe

Re: checking if a list is empty

2011-05-12 Thread Roy Smith
In article <931adaf9g...@mid.individual.net>, Gregory Ewing wrote: > Roy Smith wrote: > >>If both are numbers, they are converted to a common type. Otherwise, > >>objects of different types always compare unequal > > That's just the default treatment for unrelated types that don't > know anyth

Re: checking if a list is empty

2011-05-12 Thread Ben Finney
Hans Georg Schaathun writes: > On Thu, 12 May 2011 16:46:38 +1000, Ben Finney >wrote: > : Hans Georg Schaathun writes: > : > : > On Wed, 11 May 2011 20:31:45 -0700 (PDT), alex23 > : >wrote: > : > : On May 12, 7:24 am, harrismh777 wrote: > : > : > We need to move away from 'canned app

Re: checking if a list is empty

2011-05-12 Thread Hans Georg Schaathun
On Thu, 12 May 2011 16:46:38 +1000, Ben Finney wrote: : Hans Georg Schaathun writes: : : > On Wed, 11 May 2011 20:31:45 -0700 (PDT), alex23 : >wrote: : > : On May 12, 7:24 am, harrismh777 wrote: : > : > We need to move away from 'canned apps' to a new day where : > : > the masses can si

Re: checking if a list is empty

2011-05-12 Thread Ben Finney
Hans Georg Schaathun writes: > On Wed, 11 May 2011 20:31:45 -0700 (PDT), alex23 >wrote: > : On May 12, 7:24 am, harrismh777 wrote: > : > We need to move away from 'canned apps' to a new day where > : > the masses can sit down to their computer and solve new problems with it > : > through in

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Wed, 11 May 2011 20:31:45 -0700 (PDT), alex23 wrote: : On May 12, 7:24 am, harrismh777 wrote: : > We need to move away from 'canned apps' to a new day where : > the masses can sit down to their computer and solve new problems with it : > through intuitive language skills.  Why not? : : Be

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On 11 May 2011 21:42:10 GMT, Steven D'Aprano wrote: : *Potentially* different tests. Which is exactly the point. Given an : arbitrary object, the developer doesn't know what test is appropriate. : Should I write len(x) == 0 or list(x) == [] or x.next is None or : something else? How can I

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Thu, 12 May 2011 01:49:05 -0400, D'Arcy J.M. Cain wrote: : That's not programming. That's using a canned app that a programmer : wrote that takes your unstructured input and does something useful with : it. Spreadsheets are a primitive example of that. Google is a more : advanced examp

Re: checking if a list is empty

2011-05-11 Thread Steven D'Aprano
On Wed, 11 May 2011 22:53:45 -0500, harrismh777 wrote: > alex23 wrote: >>> through intuitive language skills. Why not? >> Because the vast majority of them don't seem to want to be bothered? >> >> > That could very well be... but I have a hope for them. I honestly think > its not because they don

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Thu, 12 May 2011 17:44:07 +1200, Gregory Ewing wrote: : Roy Smith wrote: : > Hans Georg Schaathun wrote: : >>If both are numbers, they are converted to a common type. Otherwise, : >>objects of different types always compare unequal Actually, I did not. :-- hg -- http://mail.python.org/ma

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Wed, 11 May 2011 20:16:01 -0700 (PDT), alex23 wrote: : Hans Georg Schaathun wrote: : > Revolutionary indeed, so why don't we exploit the revolution : > and write the programs to be as accessible as possible? : : Where do you draw the line, though? I said that, "as possible". You draw it

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On 11 May 2011 21:47:27 GMT, Steven D'Aprano wrote: : On Wed, 11 May 2011 20:13:35 +0100, Hans Georg Schaathun wrote: : > One principle of object oriented programming is to bestow the objects : > with properties reflecting known properties from the domain being : > modelled. Lists do not have

Re: checking if a list is empty

2011-05-11 Thread D'Arcy J.M. Cain
On Wed, 11 May 2011 16:24:47 -0500 harrismh777 wrote: > D'Arcy J.M. Cain wrote: > Non-programmers should not be expected to program in 'C' nor in lisp... > > ... but non-programmers were able to program in BASIC jes fine... They still had to learn the language. > I contend that non-prog

Re: checking if a list is empty

2011-05-11 Thread Gregory Ewing
Roy Smith wrote: Hans Georg Schaathun wrote: If both are numbers, they are converted to a common type. Otherwise, objects of different types always compare unequal That's just the default treatment for unrelated types that don't know anything about each other. I would guess that the list's =

Re: checking if a list is empty

2011-05-11 Thread harrismh777
alex23 wrote: through intuitive language skills. Why not? Because the vast majority of them don't seem to want to be bothered? That could very well be... but I have a hope for them. I honestly think its not because they don't want to be bothered, rather they just think its too far past the

Re: checking if a list is empty

2011-05-11 Thread Chris Angelico
On Thu, May 12, 2011 at 7:02 AM, Ian wrote: > In the "real world"  lists of zero items do not exist. > You don't go shopping with a shopping list of zero items. Actually, yes you do. You maintain your shopping list between trips; whenever you need something, you put it on the list immediately. Th

Re: checking if a list is empty

2011-05-11 Thread Chris Torek
In article <4dc6a39a$0$29991$c3e8da3$54964...@news.astraweb.com> Steven D'Aprano wrote: >In English, [the word "not"] negates a word or statement: > >"the cat is not on the mat" --> "the cat is on the mat" is false. As a mostly off topic aside, English is considerably more complicated than that.

Learning new languages (was: checking if a list is empty)

2011-05-11 Thread Teemu Likonen
* 2011-05-11T20:26:48+01:00 * Hans Georg Schaathun wrote: > On Wed, 11 May 2011 14:44:37 -0400, Prasad, Ramit >wrote: >> I claim to be able to program (Java/Python), but would be absolutely >> lost programming in Lisp. It is more than just "learning the syntax", >> it includes a thought paradi

Re: checking if a list is empty

2011-05-11 Thread alex23
On May 12, 7:24 am, harrismh777 wrote: > We need to move away from 'canned apps' to a new day where > the masses can sit down to their computer and solve new problems with it > through intuitive language skills.  Why not? Because the vast majority of them don't seem to want to be bothered? -- h

Re: checking if a list is empty

2011-05-11 Thread alex23
Hans Georg Schaathun wrote: > Revolutionary indeed, so why don't we exploit the revolution > and write the programs to be as accessible as possible? Where do you draw the line, though? No decorators, as they're not intuitively obvious? No custom descriptors, as that requires a deeper knowledge o

Re: checking if a list is empty

2011-05-11 Thread Steven D'Aprano
On Wed, 11 May 2011 17:38:58 -0500, harrismh777 wrote: > Steven D'Aprano wrote: >>> modelled. Lists do not have truth values in the application domain >> Yes they do. Empty lists are nothing, ergo false, and non-empty lists >> are something, ergo true. >> >> > No they don't. Empty lists are empt

Re: checking if a list is empty

2011-05-11 Thread harrismh777
harrismh777 wrote: Lists by themselves, empty or not, cannot have a 'truth' in an of themselves. ... forgot., Based on Ian's comment a couple of days ago... if alist: ... is actually : if bool(alist): I think this is more than just semantics or silly argumentation.

Re: checking if a list is empty

2011-05-11 Thread Gregory Ewing
Hans Georg Schaathun wrote: 0 is a number as real and existent as any other, one would think that the empty list is also as real and existent as any other list. 0 does have some special properties, though, such as being the additive identity and not having a multiplicative inverse. Adding fals

Re: checking if a list is empty

2011-05-11 Thread harrismh777
Steven D'Aprano wrote: modelled. Lists do not have truth values in the application domain Yes they do. Empty lists are nothing, ergo false, and non-empty lists are something, ergo true. No they don't. Empty lists are empty lists... which just happen to become False when type cast bool(lis

Re: checking if a list is empty

2011-05-11 Thread Steven Howe
On 05/11/2011 02:47 PM, Steven D'Aprano wrote: On Wed, 11 May 2011 20:13:35 +0100, Hans Georg Schaathun wrote: One principle of object oriented programming is to bestow the objects with properties reflecting known properties from the domain being modelled. Lists do not have truth values in the

Re: checking if a list is empty

2011-05-11 Thread Steven D'Aprano
On Wed, 11 May 2011 20:13:35 +0100, Hans Georg Schaathun wrote: > One principle of object oriented programming is to bestow the objects > with properties reflecting known properties from the domain being > modelled. Lists do not have truth values in the application domain Yes they do. Empty list

Re: checking if a list is empty

2011-05-11 Thread Steven D'Aprano
On Wed, 11 May 2011 19:05:03 +, Chris Torek wrote: > In article <4dcab8bf$0$29980$c3e8da3$54964...@news.astraweb.com> Steven > D'Aprano wrote: >>When you call len(x) you don't care about the details of how to >>calculate the length of x. The object itself knows so that you don't >>have to. T

Re: checking if a list is empty

2011-05-11 Thread harrismh777
D'Arcy J.M. Cain wrote: Non-programmers should be able to program? Should non-doctors be able to doctor? Should cars be built so that anyone can intuitively fix them without a mechanic? Non-programmers should not be expected to program in 'C' nor in lisp... ... but non-programmers were

Re: checking if a list is empty

2011-05-11 Thread harrismh777
Hans Georg Schaathun wrote: Code is quite often published to document algorithms, methods and formulæ for the purpose of scientific research. Since there is no universal language which suits everything and everyone, this is exactly what happens. One has to have the rudimentary knowledge to read

Re: checking if a list is empty

2011-05-11 Thread Ian
On 11/05/2011 20:13, Hans Georg Schaathun wrote: On Wed, 11 May 2011 12:17:33 -0700, Ethan Furman wrote: : 'if li' *is* KISS. It /might/ be in some contexts, but a priori it is not, as it superimposes a truth value on a data type which is otherwise a pretty accurate model of real objects (

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Wed, 11 May 2011 14:44:37 -0400, Prasad, Ramit wrote: : > Someone who knows how to program is never clueless starting a new : >language. Newbie, may be, but he knows most of the constructions : >and semantic principles to look for; most of it is learning the syntax. : : I claim to be able

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Wed, 11 May 2011 12:17:33 -0700, Ethan Furman wrote: : 'if li' *is* KISS. It /might/ be in some contexts, but a priori it is not, as it superimposes a truth value on a data type which is otherwise a pretty accurate model of real objects (outside python). One principle of object oriented pr

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Wed, 11 May 2011 14:59:34 -0400, Prasad, Ramit wrote: : Fair enough. I am a sheep, so I do what other (more knowledgeable) : people do. It is a fair assumption (for my specific code writing : environments) that everyone who is going to read my code understands : "if x:" notation or is expe

RE: checking if a list is empty

2011-05-11 Thread Prasad, Ramit
hun Sent: Wednesday, May 11, 2011 1:06 PM To: python-list@python.org Subject: Re: checking if a list is empty On 11 May 2011 16:26:40 GMT, Steven D'Aprano wrote: : > 1. My concern was not about clueless newbies. They need to : > learn. My concern is about experienced scientists and

Re: checking if a list is empty

2011-05-11 Thread Chris Torek
In article <4dcab8bf$0$29980$c3e8da3$54964...@news.astraweb.com> Steven D'Aprano wrote: >When you call len(x) you don't care about the details of how to calculate >the length of x. The object itself knows so that you don't have to. The >same applies to truth testing. > >I have a data type that

Re: checking if a list is empty

2011-05-11 Thread Ethan Furman
Hans Georg Schaathun wrote: On Wed, 11 May 2011 13:50:54 -0400, Prasad, Ramit wrote: : I find this argument to be flawed. Should I stop using built-in : generators instead of range/xrange for looping through lists? : Certainly for loops with loop counting are understood more widely : than g

RE: checking if a list is empty

2011-05-11 Thread Prasad, Ramit
rom: python-list-bounces+ramit.prasad=jpmchase@python.org [mailto:python-list-bounces+ramit.prasad=jpmchase@python.org] On Behalf Of Hans Georg Schaathun Sent: Wednesday, May 11, 2011 1:16 PM To: python-list@python.org Subject: Re: checking if a list is empty On Wed, 11 May 2011 13:50:54 -0400

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Wed, 11 May 2011 13:50:54 -0400, Prasad, Ramit wrote: : I find this argument to be flawed. Should I stop using built-in : generators instead of range/xrange for looping through lists? : Certainly for loops with loop counting are understood more widely : than generators. Should I stop using

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Wed, 11 May 2011 10:31:59 -0600, Ian Kelly wrote: : (x + 3 for x in xs if x % 2 == 1) Interesting. Thanks. That might come in handy some time. -- :-- Hans Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Wed, 11 May 2011 10:27:49 -0400, D'Arcy J.M. Cain wrote: : When did we come to the idea that people should be able to program in a : language without actually learning it? The fact that Python comes so : close to that possibility is nothing short of revolutionary. Revolutionary indeed, s

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Thu, 12 May 2011 02:05:21 +1000, Chris Angelico wrote: : In a Bourne shell script, if ends with fi... case ends with esac... so : file would end with... hmm. Yeah, I think it's best to know the : language you're trying to comprehend, and/or actually look at context : instead of shoving a

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On 11 May 2011 16:26:40 GMT, Steven D'Aprano wrote: : > 1. My concern was not about clueless newbies. They need to : > learn. My concern is about experienced scientists and engineers who : > are simply new to python. : : Which makes them clueless newbies *about Python*. I don't care how

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Wed, 11 May 2011 10:33:51 -0400, D'Arcy J.M. Cain wrote: : Non-programmers should be able to program? That was not really what I suggested; I was primarily talking about reading programs and commenting on formulæ and algorithms. : Should non-doctors be able to doctor? If I were God, I mi

  1   2   >