Why prefer != over <> for Python 3.0?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kwitters@telenet.be

    Why prefer != over <> for Python 3.0?

    I don't know if this is the right place to discuss the death of <in
    Python 3.0, or if there have been any meaningful discussions posted
    before (hard to search google with '<>' keyword), but why would anyone
    prefer the comparison operator != over <>???

    I've written an article about it to try and save this nice "is not
    equal" operator, located at http://dewitters.koonsolo.com/python_neq.html

    Please set it straight in 3.0, and if not, convince me with a good
    reason of doing so, so that I can live with it and don't have to spend
    the rest of my life in 2.x ;).
  • Carl Banks

    #2
    Re: Why prefer != over &lt;&gt; for Python 3.0?

    On Mar 29, 6:55 am, kwitt...@telene t.be wrote:
    why would anyone
    Questions that begin with the words "why would anyone" are almost
    always betray an arrogance about their own beliefs and an ignorance
    (or feigning ignorance) of human nature.

    Wiser folks know better than to phrase this question so judgmentally.

    Please set it straight in 3.0, and if not, convince me with a good
    reason of doing so, so that I can live with it and don't have to spend
    the rest of my life in 2.x ;).
    1. It's not going to change in Python 3.0.

    2. It's a silly thing to care so much about that you will avoid using
    a langauge because of it.


    Carl Banks

    Comment

    • Gabriel Genellina

      #3
      Re: Why prefer != over &lt;&gt; for Python 3.0?

      En Sat, 29 Mar 2008 16:24:01 -0300, Michael Wieher
      <michael.wieher @gmail.comescri bió:
      to me it seems simple.
      >
      C uses !=
      >
      why does C use != .... because its kind of hard to type the "equal with a
      slash"
      In C, ! by itself is the logical "not", so !(a==b) is the same as (a!=b)
      and that's rather consistent.
      Python doesn't use ! for anything else; != is rather arbitrary but
      certainly much better than <(for many objects < and are meaningless;
      being equal or not equal has nothing to do with being less or greater)

      --
      Gabriel Genellina

      Comment

      • Aahz

        #4
        Re: Why prefer != over &lt;&gt; for Python 3.0?

        In article <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y2 1g2000hsf.googl egroups.com>,
        <kwitters@telen et.bewrote:
        >
        >I don't know if this is the right place to discuss the death of <in
        >Python 3.0, or if there have been any meaningful discussions posted
        >before (hard to search google with '<>' keyword), but why would anyone
        >prefer the comparison operator != over <>???
        Are you asking why Python 3.0 gets rid of one of them or are you asking
        why != was chosen over <>?
        --
        Aahz (aahz@pythoncra ft.com) <* http://www.pythoncraft.com/

        "It is easier to optimize correct code than to correct optimized code."
        --Bill Harlan

        Comment

        • hdante

          #5
          Re: Why prefer != over &lt;&gt; for Python 3.0?

          On Mar 29, 7:55 am, kwitt...@telene t.be wrote:
          I don't know if this is the right place to discuss the death of <in
          Python 3.0, or if there have been any meaningful discussions posted
          before (hard to search google with '<>' keyword), but why would anyone
          prefer the comparison operator != over <>???
          >
          I've written an article about it to try and save this nice "is not
          equal" operator, located athttp://dewitters.koons olo.com/python_neq.html
          >
          Please set it straight in 3.0, and if not, convince me with a good
          reason of doing so, so that I can live with it and don't have to spend
          the rest of my life in 2.x ;).
          I don't know, but we should have only one operator.

          BTW, my opinion is that it's already time that programmer editors
          have input methods advanced enough for generating this:

          if x ¡Á 0:
          ¢£y ¡ô s:
          if y ¡Ã 0: f1(y)
          else: f2(y)

          ;-)

          Comment

          • Carl Banks

            #6
            Re: Why prefer != over &lt;&gt; for Python 3.0?

            On Mar 29, 9:23 pm, Steven D'Aprano <st...@REMOVE-THIS-
            cybersource.com .auwrote:
            On Sat, 29 Mar 2008 12:49:05 -0700, Carl Banks wrote:
            Please set it straight in 3.0, and if not, convince me with a good
            reason of doing so, so that I can live with it and don't have to spend
            the rest of my life in 2.x ;).
            >
            1. It's not going to change in Python 3.0.
            >
            2. It's a silly thing to care so much about that you will avoid using a
            langauge because of it.
            >
            [snip indignant rant]
            >
            But it's not silly to care
            about the feel of the language.
            I'm not exactly sure who you're arguing with, bud. No one around here
            that I can tell said anything about what you're railing against.


            Carl Banks

            Comment

            • Gabriel Genellina

              #7
              Re: Why prefer != over &lt;&gt; for Python 3.0?

              En Sun, 30 Mar 2008 02:11:33 -0300, hdante <hdante@gmail.c omescribió:
              BTW, my opinion is that it's already time that programmer editors
              have input methods advanced enough for generating this:
              >
              if x ≠ 0:
              ∀y ∈ s:
              if y ≥ 0: f1(y)
              else: f2(y)
              Fine if you have the right keyboard... Try to write APL with a standard
              keyboard :)

              --
              Gabriel Genellina

              Comment

              • Gabriel Genellina

                #8
                Re: Why prefer != over &lt;&gt; for Python 3.0?

                En Sun, 30 Mar 2008 05:08:34 -0300, <dewitters@gmai l.comescribió:
                On Mar 29, 12:41 pm, Steven D'Aprano <st...@REMOVE-THIS-
                cybersource.com .auwrote:
                >Since you jump to an invalid conclusion about !=, the rest of your
                >argument fails.
                >
                No, you said <= could be confusing, but we're talking about <here,
                and there is no confusion about that :).
                Yes, there is: <looks like "less or greater", and being equal or not is
                a different thing that being less or greater. Trichotomy law holds for
                real numbers (although some people don't even accept that) but not for
                floating point (NANs); and Python isn't about numbers only. For a lot of
                objects it makes sense to compare them for equality or not, but you can't
                say which one is greater than the other (the weather forecast, books in a
                bookstore)

                --
                Gabriel Genellina

                Comment

                • Torsten Bronger

                  #9
                  Re: Why prefer != over &lt;&gt; for Python 3.0?

                  Hallöchen!

                  Bjoern Schliessmann writes:
                  Lie wrote:
                  >
                  >Ah yes, that is also used (I completely forgot about that one, my
                  >math's aren't that sharp anymore) and I think it's used more
                  >frequently than ><.
                  >
                  Where did you read that (I mean, which country)? I've never seen
                  this sign in any german or english book on
                  mathematics/physics/engineering I saw.
                  Maybe he means "≷".
                  >but my argument was that no math book use != or <(except in
                  >math for programmers).
                  >
                  That's true. Personally, I don't ever use "a!=b" in favor of "not
                  a==b".
                  As a side note, I've always found == rather ugly. I'd prefer to
                  have = for both purposes. The constructs that wouldn't work anymore
                  are rare as far as I can see (and possibly there are even
                  workarounds).

                  Tschö,
                  Torsten.

                  --
                  Torsten Bronger, aquisgrana, europa vetus
                  Jabber ID: bronger@jabber. org
                  (See http://ime.webhop.org for further contact info.)

                  Comment

                  • Steven D'Aprano

                    #10
                    Re: Why prefer != over &lt;&gt; for Python 3.0?

                    On Sat, 29 Mar 2008 22:11:33 -0700, hdante wrote:
                    BTW, my opinion is that it's already time that programmer editors
                    have input methods advanced enough for generating this:
                    >
                    if x ≠ 0:
                    ∀y ∈ s:
                    if y ≥ 0: f1(y)
                    else: f2(y)
                    >
                    ;-)
                    Back in the 1990s, Apple's Hypercard accepted ≠ for "not equal". Of
                    course, Macs made it easy to type such special characters. By memory you
                    held down the Option key and typed an equals sign. For ≥ you used Option
                    and less-than. That worked in *any* Mac application.

                    Ah, glory days.

                    But I digress. In Python we can write the above as:


                    if x != 0:
                    [f1(y) if y >= 0 else f2(y) for y in s]


                    which for those not trained in algebra is probably more readable.



                    --
                    Steven

                    Comment

                    • bearophileHUGS@lycos.com

                      #11
                      Re: Why prefer != over &lt;&gt; for Python 3.0?

                      hdante:
                      it's already time that programmer editors
                      have input methods advanced enough for generating this:
                      if x ¡Á 0:
                      ¢£y ¡ô s:
                      if y ¡Ã 0: f1(y)
                      else: f2(y)
                      Take a look at Fortress language, by Sun. A free (slow) interpreter is
                      already available.
                      (Mathematica too allows you to write those symbols, but it costs a
                      lot, and (despite tons of good things it has) as *programming
                      language* it's awful, IHMO).


                      Steven D'Aprano:
                      In Python we can write the above as:
                      if x != 0:
                      [f1(y) if y >= 0 else f2(y) for y in s]
                      Your code builds an actual array (Python list) of results, while I
                      think the original code just calls f1/f2.

                      Bye,
                      bearophile

                      Comment

                      • hdante

                        #12
                        Re: Why prefer != over &lt;&gt; for Python 3.0?

                        On Mar 30, 2:35 am, "Gabriel Genellina" <gagsl-...@yahoo.com.a r>
                        wrote:
                        En Sun, 30 Mar 2008 02:11:33 -0300, hdante <hda...@gmail.c omescribió:
                        >
                        BTW, my opinion is that it's already time that programmer editors
                        have input methods advanced enough for generating this:
                        >
                        if x ≠ 0:
                        ∀y ∈ s:
                        if y ≥ 0: f1(y)
                        else: f2(y)
                        >
                        Fine if you have the right keyboard... Try to write APL with a standard
                        keyboard :)
                        >
                        --
                        Gabriel Genellina
                        My sugestion considered using standard keyboards (hint: read again).

                        Comment

                        • Bjoern Schliessmann

                          #13
                          Re: Why prefer != over &lt;&gt; for Python 3.0?

                          hdante wrote:
                          BTW, my opinion is that it's already time that programmer editors
                          have input methods advanced enough for generating this:
                          Could you please list some that do, and are also convenient?

                          Regards,


                          Björn

                          --
                          BOFH excuse #288:

                          Hard drive sleeping. Let it wake up on it's own...

                          Comment

                          • Bjoern Schliessmann

                            #14
                            Re: Why prefer != over &lt;&gt; for Python 3.0?

                            Torsten Bronger wrote:
                            Maybe he means "?".
                            Haven't seen this either, nor do I think it's the same than "<>".
                            From afar, it looks more like "><". But this does more look like
                            South Park style shut eyes than an operator. :)

                            Regards,


                            Björn

                            --
                            BOFH excuse #407:

                            Route flapping at the NAP.

                            Comment

                            • Torsten Bronger

                              #15
                              Re: Why prefer != over &lt;&gt; for Python 3.0?

                              Hallöchen!

                              Bjoern Schliessmann writes:
                              hdante wrote:
                              >
                              >BTW, my opinion is that it's already time that programmer editors
                              >have input methods advanced enough for generating this:
                              >
                              Could you please list some that do, and are also convenient?
                              Define "convenient ". Emacs is generally not regarded as being
                              convenient, however, it has very strong input methods. I type
                              "\gtrless" and get "≷", or "\forall" and get "∀".

                              Tschö,
                              Torsten.

                              --
                              Torsten Bronger, aquisgrana, europa vetus
                              Jabber ID: bronger@jabber. org
                              (See http://ime.webhop.org for further contact info.)

                              Comment

                              Working...