Re: Question about None

2009-06-20 Thread Paul Rubin
Paul LaFollette writes: > So, what I would like is some sort of object that is a "kind of" > everything but contains nothing, a unique minimal element of the > partial ordering imposed on the set of classes by the inheritance > heierarchy. Whilst I am not naive mathematically, I am relatively > n

Re: Question about None

2009-06-17 Thread Aaron Brady
On Jun 17, 5:47 am, Bruno Desthuilliers wrote: > John Yeung a écrit : > > But mathematically speaking, it's intuitive that "nothing" would match > > any type. > > IOW, what's the OP is after is not the None type, but some yet > unexisting "Anything" type !-) The behaviors of the 'anything' object

Re: Question about None

2009-06-17 Thread Bruno Desthuilliers
John Yeung a écrit : On Jun 13, 2:29 am, Steven D'Aprano wrote: Paul LaFollette wrote: 3) (this is purely philosophical but I am curious) Would it not be more intuitive if isinstance(None, ) returned true? Good grief no!!! None is an object. It has a type, NoneType. It's *not* a string, or a

Re: Question about None

2009-06-15 Thread Terry Reedy
Steven D'Aprano wrote: On Sun, 14 Jun 2009 19:14:10 -0400, Terry Reedy wrote: Steven D'Aprano wrote: So-called "vacuous truth". It's often useful to have all([]) return true, but it's not *always* useful -- there are reasonable cases where the opposite behaviour would be useful: [...] It see

Re: Question about None

2009-06-15 Thread Aaron Brady
On Jun 14, 9:50 pm, Steven D'Aprano wrote: > On Sun, 14 Jun 2009 19:14:10 -0400, Terry Reedy wrote: > > Steven D'Aprano wrote: > > >> So-called "vacuous truth". It's often useful to have all([]) return > >> true, but it's not *always* useful -- there are reasonable cases where > >> the opposite be

Re: Question about None

2009-06-14 Thread Steven D'Aprano
On Sun, 14 Jun 2009 19:14:10 -0400, Terry Reedy wrote: > Steven D'Aprano wrote: >> >> So-called "vacuous truth". It's often useful to have all([]) return >> true, but it's not *always* useful -- there are reasonable cases where >> the opposite behaviour would be useful: [...] > It seems to me tha

Re: Question about None

2009-06-14 Thread Steven D'Aprano
On Sun, 14 Jun 2009 18:02:54 +0100, Arnaud Delobelle wrote: > Steven D'Aprano writes: >> So-called "vacuous truth". It's often useful to have all([]) return >> true, but it's not *always* useful -- there are reasonable cases where >> the opposite behaviour would be useful: >> >> if all(the eviden

Re: Question about None

2009-06-14 Thread Aaron Brady
On Jun 14, 12:37 pm, Paul Rubin wrote: > Andre Engels writes: snip > > type "thingy". A car is a single car. Nothing is zero cars, which is > > not a car, just like two cars is not a car. > > That seems to confuse values with collections of them.  A car is not > the

Re: Question about None

2009-06-14 Thread Terry Reedy
Paul LaFollette wrote: Thank you all for your thoughtful and useful comments. Since this has largely morphed into a discussion of my 3rd question, perhaps it would interest you to hear my reason for asking it. John is just about spot on. Part of my research involves the enumeration and generati

Re: Question about None

2009-06-14 Thread Terry Reedy
Mel wrote: John Yeung wrote: And I accept your answer, as well as Steven's and Paul's for that matter. I still think it is understandable (and people may choose to understand in a condescending way, if they wish) that someone might not get the difference between what you are saying and the sta

Re: Question about None

2009-06-14 Thread Terry Reedy
Steven D'Aprano wrote: So-called "vacuous truth". It's often useful to have all([]) return true, but it's not *always* useful -- there are reasonable cases where the opposite behaviour would be useful: if all(the evidence points to the Defendant's guilt) then: the Defendant is guilty execute(th

Re: Question about None

2009-06-14 Thread Paul Rubin
Andre Engels writes: > I was making a point that I don't agree that "nothing" would match any > type. The reason was that anything of the type car is one car, not two > cars or zero cars, but "nothing" is zero cars. You don't agree with > me, so apparently you are of the opinion that "nothing" wou

Re: Question about None

2009-06-14 Thread Andre Engels
On Sun, Jun 14, 2009 at 10:21 PM, Paul Rubin wrote: > Andre Engels writes: >> > That seems to confuse values with collections of them.  A car is not >> > the same as a one-element list of cars.  Nothing is not the same as a >> > zero-element list of cars. >> >> So y

Re: Question about None

2009-06-14 Thread Paul Rubin
Andre Engels writes: > > That seems to confuse values with collections of them.  A car is not > > the same as a one-element list of cars.  Nothing is not the same as a > > zero-element list of cars. > > So you are of the opinion that "nothing" _is_ a car? Eh? No of course not. a != b and b !

Re: Question about None

2009-06-14 Thread Andre Engels
On Sun, Jun 14, 2009 at 9:37 PM, Paul Rubin wrote: > Andre Engels writes: >> I don't see why that would be the case. Something of the type "thingy" >> is ONE thingy. Nothing is ZERO thingies, so it is not something of the >> type "thingy". A car is a single car. Nothi

Re: Question about None

2009-06-14 Thread Paul Rubin
Andre Engels writes: > I don't see why that would be the case. Something of the type "thingy" > is ONE thingy. Nothing is ZERO thingies, so it is not something of the > type "thingy". A car is a single car. Nothing is zero cars, which is > not a car, just like two cars is not a car. That seems to

Re: Question about None

2009-06-14 Thread Aaron Brady
On Jun 14, 10:02 am, Arnaud Delobelle wrote: snip > guilt, it doesn't mean they will be convicted.  There needs to be enough > evidence to convince the jury.  So it would be something like: > > if sum(guilt_weight(e) for e in evidence) > GUILT_THRESHOLD: >    the defendant is guilty >    ... > > -

Re: Question about None

2009-06-14 Thread MRAB
Andre Engels wrote: On Sun, Jun 14, 2009 at 6:49 PM, Paul LaFollette wrote: Now, suppose that I want to generate, say, the set of all ordered trees with N nodes. I need to be able to represent the empty ordered tree, i.e. the tree with with zero nodes. There are a lot of ways I could do this.

Re: Question about None

2009-06-14 Thread Andre Engels
On Sun, Jun 14, 2009 at 6:49 PM, Paul LaFollette wrote: > Now, suppose that I want to generate, say, the set of all ordered > trees with N nodes.   I need to be able to represent the empty ordered > tree, i.e. the tree with with zero nodes.  There are a lot of ways I > could do this.  The problem i

Re: Question about None

2009-06-14 Thread Arnaud Delobelle
Steven D'Aprano writes: > So-called "vacuous truth". It's often useful to have all([]) return true, > but it's not *always* useful -- there are reasonable cases where the > opposite behaviour would be useful: > > if all(the evidence points to the Defendant's guilt) then: > the Defendant is gui

Re: Question about None

2009-06-14 Thread Paul LaFollette
Thank you all for your thoughtful and useful comments. Since this has largely morphed into a discussion of my 3rd question, perhaps it would interest you to hear my reason for asking it. John is just about spot on. Part of my research involves the enumeration and generation of various combinatori

Re: Question about None

2009-06-14 Thread Andre Engels
On Sat, Jun 13, 2009 at 7:23 PM, John Yeung wrote: > Paul LaFollette is probably thinking along the lines of formal logic > or set theory.  It's a little bit confused because programming isn't > quite the same as math, and so it's a common question when designing > and implementing programming lan

Re: Question about None

2009-06-14 Thread Piet van Oostrum
> John Yeung (JY) wrote: >JY> I've never heard a mathematician use the term "bottom". It certainly >JY> could be that I just haven't talked to the right types of >JY> mathematicians. "Bottom" is a term from lattice theory, which is a branch of mathematics. -- Piet van Oostrum URL: http:

Re: Question about None

2009-06-14 Thread Mel
John Yeung wrote: > And I accept your answer, as well as Steven's and Paul's for that > matter. I still think it is understandable (and people may choose to > understand in a condescending way, if they wish) that someone might > not get the difference between what you are saying and the statement

Re: Question about None

2009-06-14 Thread Scott David Daniels
Steven D'Aprano wrote: ... or {1}∩0. (If that character between the set and zero ends up missing, it's meant to be INTERSECTION u'\u2229'.) Note that you can write this in a quite readable way in ASCII: "it's meant to be the character u'\N{INTERSECTION}'." --Scott David Daniels scott.dani..

Re: Question about None

2009-06-14 Thread Steven D'Aprano
John Yeung wrote: > Paul LaFollette is probably thinking along the lines of formal logic > or set theory. It's a little bit confused because programming isn't > quite the same as math, and so it's a common question when designing > and implementing programming languages how far to take certain >

Re: Question about None

2009-06-13 Thread John O'Hagan
On Sat, 13 Jun 2009, John Yeung wrote: > On Jun 13, 5:22 pm, "Rhodri James" > > wrote: > > Such an understanding would be clearly wrong in the context > > in which we were talking (and denotational semantics is a > > branch of category theory, which is not specific to computer > > science if you d

Re: Question about None

2009-06-13 Thread Piet van Oostrum
> Paul Rubin (PR) wrote: >PR> Paul Rubin writes: >>> crash, or something like that. None is a value which in Haskell has a >PR> I got ahead of myself, of course I meant Python (the *next* sentence >PR> was going to mention Haskell

Re: Question about None

2009-06-13 Thread John Yeung
On Jun 13, 5:22 pm, "Rhodri James" wrote: > Such an understanding would be clearly wrong in the context > in which we were talking (and denotational semantics is a > branch of category theory, which is not specific to computer > science if you don't mind).  If None is nothing, then it can't > be a

Re: Question about None

2009-06-13 Thread Rhodri James
On Sat, 13 Jun 2009 21:25:28 +0100, John Yeung wrote: > But mathematically speaking, it's intuitive that > "nothing" would match any type. Completely wrong.  The concept you're thinking of in denotational semantics is called "bottom", but bottom is not a value that functions can compute and

Re: Question about None

2009-06-13 Thread John Yeung
On Jun 13, 1:49 pm, Paul Rubin wrote: > John Yeung writes: > > Because you might want None to behave as though it were > > nothing at all. > > Sure, you might also want strings to behave as if they > were ints, but wishing doesn't make it so. I'm not saying that the

Re: Question about None

2009-06-13 Thread Paul Rubin
Paul Rubin writes: > crash, or something like that. None is a value which in Haskell has a I got ahead of myself, of course I meant Python (the *next* sentence was going to mention Haskell). The corresponding concept in Haskell is called Nothing, which lives in a t

Re: Question about None

2009-06-13 Thread Paul Rubin
John Yeung writes: > Because you might want None to behave as though it were nothing at all. Sure, you might also want strings to behave as if they were ints, but wishing doesn't make it so. > But mathematically speaking, it's intuitive that "nothing" would match > any type. Completely wrong.

Re: Question about None

2009-06-13 Thread John Yeung
On Jun 13, 2:29 am, Steven D'Aprano wrote: > Paul LaFollette wrote: > > 3) (this is purely philosophical but I am curious) > > Would it not be more intuitive if > > isinstance(None, ) returned true? > > Good grief no!!! > > None is an object. It has a type, NoneType. It's *not* a > string, or a fl

Re: Question about None

2009-06-13 Thread Terry Reedy
Steven D'Aprano wrote: [ snip excellent discussion of proper use of assert] The third bug (the nitpick) is a bug in the API: you name the argument "nxt" with no e, but in the error message, you call it "next" with an e. The fact that any intelligent person should be able to guess what parameter

Re: Question about None

2009-06-12 Thread Steven D'Aprano
Jean-Michel Pichavant wrote: > >> def setNext(nxt): >> assert nxt==None or isinstance(nxt, Node), "next must be a Node" >> self.next = nxt >> >> works ok, but it's uglier than it ought to be. >> >> > I don't find it that ugly. It's accurate, easy to read and understand. Actually, it

Re: Question about None

2009-06-12 Thread Steven D'Aprano
Paul LaFollette wrote: > 3) (this is purely philosophical but I am curious) Would it not be > more intuitive if > isinstance(None, ) returned true? Good grief no!!! None is an object. It has a type, NoneType. It's *not* a string, or a float, or an int, or a list, so why would you want isinstanc

Re: Question about None

2009-06-12 Thread Robert Kern
On 2009-06-12 09:05, Paul LaFollette wrote: Kind people, Using Python 3.0 on a Gatesware machine (XP). I am building a class in which I want to constrain the types that can be stored in various instance variables. For instance, I want to be certain that self.loc contains an int. This is straig

Re: Question about None

2009-06-12 Thread Terry Reedy
Paul LaFollette wrote: since type(Node) responds with but the assertion above gives "name 'NoneType' is not defined" suggesting that NoneType is some sort of quasi-class. add NoneType = type(None) before using Nonetype -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about None

2009-06-12 Thread Jean-Michel Pichavant
def setNext(nxt): assert nxt==None or isinstance(nxt, Node), "next must be a Node" self.next = nxt works ok, but it's uglier than it ought to be. I don't find it that ugly. It's accurate, easy to read and understand. "What else ?" would say a famous coffee representative. If you

Re: Question about None

2009-06-12 Thread Javier Collado
Hello, You're right, types.NoneType is not available in python 3.0, I wasn't aware of that change. Thanks for pointing it out. Best regards, Javier 2009/6/12 Jeff McNeil : > On Jun 12, 10:05 am, Paul LaFollette > wrote: >> Kind people, >> >> Using Python 3.0 on a Gatesware machine (XP). >>

Re: Question about None

2009-06-12 Thread Jeff McNeil
On Jun 12, 10:05 am, Paul LaFollette wrote: > Kind people, > > Using Python 3.0 on a Gatesware machine (XP). > I am building a class in which I want to constrain the types that can > be stored in various instance variables.  For instance, I want to be > certain that self.loc contains an int.  This

Re: Question about None

2009-06-12 Thread Bruno Desthuilliers
Paul LaFollette a écrit : Kind people, Using Python 3.0 on a Gatesware machine (XP). I am building a class in which I want to constrain the types that can be stored in various instance variables. This somehow goes against the whole philosophy of dynamic typing Python is based upon... But ther

Re: Question about None

2009-06-12 Thread Christian Heimes
Paul LaFollette schrieb: > Kind people, > > Using Python 3.0 on a Gatesware machine (XP). > I am building a class in which I want to constrain the types that can > be stored in various instance variables. For instance, I want to be > certain that self.loc contains an int. This is straightforward

Re: Question about None

2009-06-12 Thread Javier Collado
Hello, This should work for you: In [1]: import types In [2]: isinstance(None, types.NoneType) Out[2]: True Best regards, Javier 2009/6/12 Paul LaFollette : > Kind people, > > Using Python 3.0 on a Gatesware machine (XP). > I am building a class in which I want to constrain the types that

Question about None

2009-06-12 Thread Paul LaFollette
Kind people, Using Python 3.0 on a Gatesware machine (XP). I am building a class in which I want to constrain the types that can be stored in various instance variables. For instance, I want to be certain that self.loc contains an int. This is straightforward (as long as I maintain the disciplin

Re: Quick question about None and comparisons

2008-11-25 Thread Giampaolo Rodola'
Ok thanks. I'll avoid to do that. --- Giampaolo http://code.google.com/p/pyftpdlib/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Quick question about None and comparisons

2008-11-24 Thread Chris Rebert
On Mon, Nov 24, 2008 at 5:52 PM, Giampaolo Rodola' <[EMAIL PROTECTED]> wrote: > Sorry for the title but I didn't find anything more appropriate. > To have a less verbose code would it be ok doing: > > if a > b: > > ...instead of: > > if a is not None and a > b: > > ...? > Is there any hidden compli

Re: Quick question about None and comparisons

2008-11-24 Thread r
On Nov 24, 7:52 pm, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > Sorry for the title but I didn't find anything more appropriate. > To have a less verbose code would it be ok doing: > > if a > b: > > ...instead of: > > if a is not None and a > b: > > ...? > Is there any hidden complication behi

Quick question about None and comparisons

2008-11-24 Thread Giampaolo Rodola'
Sorry for the title but I didn't find anything more appropriate. To have a less verbose code would it be ok doing: if a > b: ...instead of: if a is not None and a > b: ...? Is there any hidden complication behind that? Thanks in advance --- Giampaolo code.google.com/p/pyftpdlib/ -- http://ma

Re: Question about 'None'

2005-01-28 Thread Francis Girard
Le vendredi 28 Janvier 2005 22:54, jfj a écrit : > Francis Girard wrote: > > What was the goal behind this rule ? > > If you have a list which contains integers, strings, tuples, lists and > dicts and you sort it and print it, it will be easier to detect what > you're looking for:) > > > G. Mmm. C

Re: Question about 'None'

2005-01-28 Thread jfj
Francis Girard wrote: What was the goal behind this rule ? If you have a list which contains integers, strings, tuples, lists and dicts and you sort it and print it, it will be easier to detect what you're looking for:) G. -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about 'None'

2005-01-28 Thread Alex Martelli
flamesrock <[EMAIL PROTECTED]> wrote: ... > (The reason I ask is sortof unrelated. I wanted to use None as a > variable for which any integer, including negative ones have a greater > value so that I wouldn't need to implement any tests or initializations > for a loop that finds the maximum of a

Re: Question about 'None'

2005-01-27 Thread Jeff Shannon
flamesrock wrote: I should also mention that I'm using version 2.0.1 (schools retro solaris machines :( ) At home (version 2.3.4) it prints out 'True' for the above code block. That would explain it -- as /F mentioned previously, the special case for None was added in 2.1. Jeff Shannon Technician

Re: Question about 'None'

2005-01-27 Thread flamesrock
Wow! Thanks for all the replies. I'll have to reread everything to absorb it. The test code is pretty simple: if 2 > None: print 'true' else: print 'false' It prints false every time. I should also mention that I'm using version 2.0.1 (schools retro solaris machines :( ) At home (version 2.3.4) i

Re: Question about 'None'

2005-01-27 Thread Steven Bethard
Francis Girard wrote: a = "10" b = 10 a > b True b > a False id(a) 1077467584 id(b) 134536516 Just to thoroughly explain this example, the current CPython implementation says that numbers are smaller than everything but None. The reason you get such a small id for 'b' is that there is only one 10

Re: Question about 'None'

2005-01-27 Thread Francis Girard
Very complete explanation. Thank you Francis Girard Le jeudi 27 Janvier 2005 22:15, Steven Bethard a écrit : > Francis Girard wrote: > > I see. There is some rule stating that all the strings are greater than > > ints and smaller than lists, etc. > > Yes, that rule being to compare objects of dif

Re: Question about 'None'

2005-01-27 Thread Steven Bethard
Francis Girard wrote: I see. There is some rule stating that all the strings are greater than ints and smaller than lists, etc. Yes, that rule being to compare objects of different types by their type names (falling back to the address of the type object if the type names are the same, I believe

Re: Question about 'None'

2005-01-27 Thread Francis Girard
Le jeudi 27 Janvier 2005 22:07, Steven Bethard a écrit : > Francis Girard wrote: > > Le jeudi 27 Janvier 2005 21:29, Steven Bethard a écrit : > >>So None being smaller than anything (except itself) is hard-coded into > >>Python's compare routine. My suspicion is that even if/when objects of > >>di

Re: Question about 'None'

2005-01-27 Thread Steven Bethard
Francis Girard wrote: Le jeudi 27 Janvier 2005 21:29, Steven Bethard a écrit : So None being smaller than anything (except itself) is hard-coded into Python's compare routine. My suspicion is that even if/when objects of different types are no longer comparable by default (as has been suggested fo

Re: Question about 'None'

2005-01-27 Thread Francis Girard
Le vendredi 28 Janvier 2005 07:49, jfj a écrit : > Francis Girard wrote: > > Wow ! What is it that are compared ? I think it's the references (i.e. > > the adresses) that are compared. The "None" reference may map to the > > physical 0x0 adress whereas 100 is internally interpreted as an object > >

Re: Question about 'None'

2005-01-27 Thread Francis Girard
Oops, I misunderstood what you said. I understood that it was now the case that objects of different types are not comparable by default whereas you meant it as a planned feature for version 3. I really hope that it will indeed be the case for version 3. Francis Girard Le jeudi 27 Janvier 2005

Re: Question about 'None'

2005-01-27 Thread Fredrik Lundh
Francis Girard wrote: > Wow ! What is it that are compared ? I think it's the references (i.e. the > adresses) that are compared. The "None" reference may map to the physical 0x0 > adress whereas 100 is internally interpreted as an object for which the > reference (i.e. address) exists and therefo

Re: Question about 'None'

2005-01-27 Thread Francis Girard
Le jeudi 27 Janvier 2005 21:29, Steven Bethard a écrit : > Francis Girard wrote: > > Le jeudi 27 Janvier 2005 20:16, Steven Bethard a écrit : > >>flamesrock wrote: > >>>The statement (1 > None) is false (or any other value above 0). Why is > >>>this? > >> > >>What code are you executing? I don't g

Re: Question about 'None'

2005-01-27 Thread Fredrik Lundh
Steven Bethard wrote: > So None being smaller than anything (except itself) is hard-coded into > Python's compare routine. > My suspicion is that even if/when objects of different types are no longer > comparable by default > (as has been suggested for Python 3.0), None will still compare as s

Re: Question about 'None'

2005-01-27 Thread jfj
Francis Girard wrote: Wow ! What is it that are compared ? I think it's the references (i.e. the adresses) that are compared. The "None" reference may map to the physical 0x0 adress whereas 100 is internally interpreted as an object for which the reference (i.e. address) exists and therefore gre

Re: Question about 'None'

2005-01-27 Thread Steven Bethard
Francis Girard wrote: Le jeudi 27 Janvier 2005 20:16, Steven Bethard a écrit : flamesrock wrote: The statement (1 > None) is false (or any other value above 0). Why is this? What code are you executing? I don't get this behavior at all: py> 100 > None True py> 1 > None True py> 0 > None True py> -

Re: Question about 'None'

2005-01-27 Thread Francis Girard
Le jeudi 27 Janvier 2005 20:16, Steven Bethard a écrit : > flamesrock wrote: > > The statement (1 > None) is false (or any other value above 0). Why is > > this? > > What code are you executing? I don't get this behavior at all: > > py> 100 > None > True > py> 1 > None > True > py> 0 > None > True

Re: Question about 'None'

2005-01-27 Thread Steven Bethard
flamesrock wrote: The statement (1 > None) is false (or any other value above 0). Why is this? What code are you executing? I don't get this behavior at all: py> 100 > None True py> 1 > None True py> 0 > None True py> -1 > None True py> -100 > None True (The reason I ask is sortof unrelated. I wan

Re: Question about 'None'

2005-01-27 Thread Fredrik Lundh
"flamesrock" <[EMAIL PROTECTED]> wrote: > The statement (1 > None) is false (or any other value above 0). Why is > this? http://docs.python.org/ref/comparisons.html "The operators <, >, ==, >=, <=, and != compare the values of two objects. The objects need not have the same type. If both

Question about 'None'

2005-01-27 Thread flamesrock
Well, after playing with python for a bit I came across something weird: The statement (1 > None) is false (or any other value above 0). Why is this? (The reason I ask is sortof unrelated. I wanted to use None as a variable for which any integer, including negative ones have a greater value so t