Why prefer != over <> for Python 3.0?

B

Bjoern Schliessmann

Lie said:
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.
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".

Regards,


Björn

--
BOFH excuse #282:

High altitude condensation from U.S.A.F prototype aircraft has
contaminated the primary subnet mask. Turn off your computer for 9
days to avoid damaging it.
 
S

Steven D'Aprano

What I meant was that both < and > are standard mathematics operators,
and that by that knowledge one could deduce what <> means.

But you would be wrong, because "less than or greater than" is not the
same as "not equal to".

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: no ordering relation is defined for complex numbers
 
T

Torsten Bronger

Hallöchen!

Bjoern said:
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 "≷".
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.
 
S

Steven D'Aprano

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.
 
B

bearophileHUGS

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
 
B

Bjoern Schliessmann

hdante said:
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
 
B

Bjoern Schliessmann

Torsten said:
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
 
T

Torsten Bronger

Hallöchen!

Bjoern said:
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.
 
M

MRAB

Fine if you have the right keyboard... Try to write APL with a standard
keyboard :)
There was a version of APL for the Sinclair QL which replaced the
standard APL symbols with keywords.
 
C

Colin J. Williams

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 ;).

Algol 60 had no such operator.
Algol-W had (not)= [(not) was a negative
symbol, not on our current keyboard]
Simula 67 introduced <>
Pascal uses <> [Pascal is still
available - http://www.freepascal.org/]
C uses !=
[http://cermics.enpc.fr/~ts/C/CONCEPT/expressions.html#rel]

I prefer <> but I feel that it's better
not to have two ways of representing
not equal.

The powers that be have chosen !=. I
accept this on the grounds that current
languages seem to have nade that choice.

Colin W.
 
D

Dan Bishop

Hallöchen!




Maybe he means "≷".



As a side note, I've always found == rather ugly. I'd prefer to
have = for both purposes.

The earliest versions of Python *did* use = for both purposes.
The constructs that wouldn't work anymore
are rare as far as I can see (and possibly there are even
workarounds).

The construct a = b == c could be rewritten as a = (b = c).
 
L

Lie

Haven't seen this either, nor do I think it's the same than "<>".
From afar, it looks more like "><".

Actually I meant an X-like symbol that is made not by crossing but by
<. I retracted saying it is the standard, now that I think about it
the last time I saw >< was in elementary school (although it stuck on
my head better than a crossed =, which I first met in high school).
But this does more look like
South Park style shut eyes than an operator. :)

lol, I agree, it looks too much like closed eye smiley. Forums might
automatically convert them to graphic smileys so it is obviously a bad
choice if it is to be used.
 
L

Lie

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.

It was in my elementary school at Indonesia (FYI, it is also used as
antonym sign in languages (at least in my country)). And I think I'll
retract that claim, >< wasn't the standard, a crossed = is the
standard (btw, with a little imagination != looks like a crossed =).
 
L

Lie

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)

That would be a nightmare.

Programming language (or most computer-based texts) should only use
basic ASCII characters, except if it can't be helped since typing non-
ASCII characters is still unreliable. It'd also be a headache to
memorize what keyboard combinations to use to type a character. Not to
mention how much more complex would the keyboard design be. Also not
mentioning how much more complex the language design would be to
handle all those non-ASCII characters.
 
G

Gabriel Genellina

There was a version of APL for the Sinclair QL which replaced the
standard APL symbols with keywords.

Wow, APL on 8 bits?
Now there is (or perhaps there was) J, a reincarnation of APL by Iverson
himself that uses ASCII characters only.
 
D

Dan Bishop

....snip...

You're forcing your argument too much, both != and <> are NOT standard
mathematics operators -- the standard not-equal operator is >< -- and
I can assure you that both != and <> won't be comprehensible to non-
programmers.

A lot of non-programmers use Microsoft Excel, which uses <> for the
Not Equal operator.

FWIW, the non-programmers on one forum I post on tend to use =/= .
 
T

Torsten Bronger

Hallöchen!
AFAICT there's none. This should be easy to implement on emacs,

It *is* implemented in Emacs. You can even choose from many input
methods, optimised for differend areas/languages.

Tschö,
Torsten.
 
H

hdante

That would be a nightmare.

Programming language (or most computer-based texts) should only use
basic ASCII characters, except if it can't be helped since typing non-

I completely disagree. Unicode should be used whenever the
architecture doesn't have memory restrictions. For general
(plain-)text there's no sense in talking about ASCII. The only
language that "fits" in it that I can remember is Latin.
ASCII characters is still unreliable. It'd also be a headache to
memorize what keyboard combinations to use to type a character. Not to

You'd have to memorize, for example "!=" and ">=".
mention how much more complex would the keyboard design be. Also not

The keyboard would be the same.
mentioning how much more complex the language design would be to
handle all those non-ASCII characters.

Wrong.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top