Re: Re: Simple Python question for some

Discussion in 'Python' started by Evan Driscoll, Oct 29, 2012.

  1. On 10/28/2012 7:18 PM, Chris Rebert wrote:
    > This is fixed in Python 3, where such nonsensical comparisons will
    > instead raise TypeError.


    It's worth pointing out that at least one kind of inequality comparison
    which some people (e.g. me) would consider nonsensical is still allowed
    in Python 3, which is between Boolean values and numbers:

    >>> True < 1

    False
    >>> False < 1

    True

    which is probably because

    >>> True == 1

    True
    >>> False == 0

    True

    Many people (probably most people, to be honest) disagree with me that
    this is wrong, but regardless of whether you like it or not you need to
    know what happens in such cases.


    On 10/28/2012 7:18 PM, Chris Angelico wrote:
    > Which means that strings will ALWAYS be compared as strings, and
    > numbers will ALWAYS be compared as numbers, and ne'er the twain shall
    > conflict. I can trust Python to compare MD5 hashes reliably:
    >
    >>>> "912128034267498495410681495015e0" !=00912128034267498495410681495015"

    > True
    >
    > Of course, I'm not pointing fingers at any other languages here, but
    > this is a known security hole in one rather widely-used one.


    If you are PerHaPs talking about the language I think you are, my
    favorite fact about that is I'm that I think a while back I saw a bug
    entry about something like that and they weren't sure how or even if it
    should be fixed.

    Evan
     
    Evan Driscoll, Oct 29, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric
    Replies:
    2
    Views:
    1,509
    Tommy
    Feb 13, 2004
  2. Mark Lawrence

    Re: Simple Python question for some

    Mark Lawrence, Oct 29, 2012, in forum: Python
    Replies:
    0
    Views:
    130
    Mark Lawrence
    Oct 29, 2012
  3. Chris Rebert

    Re: Simple Python question for some

    Chris Rebert, Oct 29, 2012, in forum: Python
    Replies:
    0
    Views:
    164
    Chris Rebert
    Oct 29, 2012
  4. Chris Angelico

    Re: Simple Python question for some

    Chris Angelico, Oct 29, 2012, in forum: Python
    Replies:
    0
    Views:
    169
    Chris Angelico
    Oct 29, 2012
  5. Chris Angelico

    Re: Re: Simple Python question for some

    Chris Angelico, Oct 29, 2012, in forum: Python
    Replies:
    0
    Views:
    163
    Chris Angelico
    Oct 29, 2012
Loading...

Share This Page