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


Groups > comp.lang.python > #64991

Re:1 > 0 == True -> False

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.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.033
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'fixes': 0.07; 'derived': 0.09; 'exception.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'true)': 0.09; 'undefined': 0.09; 'python': 0.11; 'wrote': 0.14; 'does,': 0.16; 'mine.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'typeerror:': 0.16; 'undefined.': 0.16; 'saying': 0.22; 'compare': 0.26; 'purposes': 0.26; 'header:X-Complaints-To:1': 0.27; 'needed.': 0.30; '>>>>': 0.31; 'comparison': 0.31; 'default,': 0.31; 'sep': 0.31; 'types.': 0.31; 'class': 0.32; 'another': 0.32; 'third': 0.33; 'except': 0.35; 'objects': 0.35; 'but': 0.35; 'false': 0.36; 'instances': 0.36; 'ordered': 0.36; 'doing': 0.36; 'should': 0.36; 'half': 0.37; 'two': 0.37; 'expected': 0.38; 'question,': 0.38; 'to:addr:python-list': 0.38; 'expect': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'even': 0.60; 'skip:u 10': 0.60; 'expression': 0.60; 'solve': 0.60; 'tell': 0.60; "you're": 0.61; 'first': 0.61; 'more': 0.64; 'different': 0.65; 'here': 0.66; 'between': 0.67; 'results': 0.69; 'guaranteed': 0.75; 'subject::': 0.85; '2013,': 0.91; 'reasons,': 0.91; 'subject:True': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dave Angel <davea@davea.name>
Subject Re:1 > 0 == True -> False
Date Thu, 30 Jan 2014 07:49:19 -0500 (EST)
Organization news.gmane.org
References <99b0aa22-5fb3-460a-a080-dacb1c0f2fda@googlegroups.com>
X-Gmane-NNTP-Posting-Host dpc6744192077.direcpc.com
X-Newsreader PiaoHong Usenet NewsReaders 1.36
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.6129.1391086019.18130.python-list@python.org> (permalink)
Lines 50
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391086019 news.xs4all.nl 2862 [2001:888:2000:d::a6]:50567
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:64991

Show key headers only | View raw


 Thibault Langlois <thibault.langlois@gmail.com> Wrote in message:
> Hello,
> 
> $ python
> Python 2.7.4 (default, Sep 26 2013, 03:20:26) 
> [GCC 4.7.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> 1 > 0 == True
> False
>>>> (1 > 0) == True
> True
>>>> 1 > (0 == True)
> True
>>>>
> 
> What am I missing here ?
> 
> T.
> 

You tell us. You supply only half the question,  what it does,
 without saying what you expected or needed. 

I expect you're either confused about comparison chaining or about
 what happens when you compare objects of different types.
 

Doing an ordered comparison between two types is undefined by
 default, and not guaranteed to even give the same result between
 builds.  So the following may give different results on your
 2.7.4 than on mine.
        5 < "abc"

Python 3 fixes that by throwing an exception.  TypeError:
 unorderable types

This should solve it, since the first and third expression would
 seem to be undefined. Unfortunately there's yet another wrinkle.
 

For hysterical reasons,  True and False are instances of class
 bool, which is derived from int. So for comparison purposes
 False==0 and True==1. But in my opinion,  you should never take
 advantage of this, except when entering obfuscation
 contests.


-- 
DaveA

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


Thread

1 > 0 == True -> False Thibault Langlois <thibault.langlois@gmail.com> - 2014-01-30 03:36 -0800
  Re: 1 > 0 == True -> False Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2014-01-30 12:44 +0100
  Re: 1 > 0 == True -> False Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-01-30 13:46 +0200
    Re: 1 > 0 == True -> False Peter Otten <__peter__@web.de> - 2014-01-30 13:04 +0100
      Re: 1 > 0 == True -> False Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-01-30 14:08 +0200
  Re:1 > 0 == True -> False Dave Angel <davea@davea.name> - 2014-01-30 07:49 -0500
    Re: 1 > 0 == True -> False Thibault Langlois <thibault.langlois@gmail.com> - 2014-01-30 05:40 -0800
      Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 00:55 +1100
      Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 09:08 -0500
        Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 01:18 +1100
          Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 09:49 -0500
            Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 02:02 +1100
        Re: 1 > 0 == True -> False Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-01-30 06:41 -0800
        Re: 1 > 0 == True -> False Thibault Langlois <thibault.langlois@gmail.com> - 2014-01-30 06:46 -0800
          Re: 1 > 0 == True -> False Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-30 17:42 +0000
        Re: 1 > 0 == True -> False Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-01-30 16:56 +0200
          Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 10:46 -0800
            Re: 1 > 0 == True -> False Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-01-30 22:14 +0200
              Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 07:25 +1100
        Re: 1 > 0 == True -> False Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-30 15:09 +0000
          Re: 1 > 0 == True -> False Rustom Mody <rustompmody@gmail.com> - 2014-01-30 07:34 -0800
          Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 10:53 -0800
            Re: 1 > 0 == True -> False Rustom Mody <rustompmody@gmail.com> - 2014-01-30 19:33 -0800
          Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 10:56 -0800
            Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 06:03 +1100
              Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 14:09 -0800
                Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 09:29 +1100
            Re: 1 > 0 == True -> False Ethan Furman <ethan@stoneleaf.us> - 2014-01-30 11:22 -0800
            Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 06:48 +1100
    Re: 1 > 0 == True -> False Rotwang <sg552@hotmail.co.uk> - 2014-01-30 19:25 +0000
      Re: 1 > 0 == True -> False Dave Angel <davea@davea.name> - 2014-01-30 15:08 -0500
      Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 07:15 +1100
      Re: 1 > 0 == True -> False Ian Kelly <ian.g.kelly@gmail.com> - 2014-01-30 13:28 -0700
      Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 07:38 +1100
      Re: 1 > 0 == True -> False Ian Kelly <ian.g.kelly@gmail.com> - 2014-01-30 14:17 -0700
      Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 08:31 +1100
      Re: 1 > 0 == True -> False Joshua Landau <joshua@landau.ws> - 2014-01-30 23:36 +0000
        Re: 1 > 0 == True -> False Rotwang <sg552@hotmail.co.uk> - 2014-01-31 00:10 +0000
          Removal of iterable unpacking in function calls (was: 1 > 0 == True -> False) Ben Finney <ben+python@benfinney.id.au> - 2014-01-31 11:21 +1100
            Re: Removal of iterable unpacking in function calls Rotwang <sg552@hotmail.co.uk> - 2014-01-31 00:32 +0000
          Re: 1 > 0 == True -> False Joshua Landau <joshua@landau.ws> - 2014-01-31 00:32 +0000
      Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 11:01 +1100

csiph-web