Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
862 views
in Technique[技术] by (71.8m points)

syntax - What does `<>` mean in Python?

I'm trying to use in Python 3.3 an old library (dating from 2003!). When I import it, Python throws me an error because there are <> signs in the source file, e.g.:

if (cnum < 1000 and nnum <> 1000 and ntext[-1] <> "s":
    ...

I guess it's a now-abandoned sign in the language.

What exactly does it mean, and which (more recent) sign should I replace it with?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It means not equal to. It was taken from ABC (python's predecessor) see here:

x < y, x <= y, x >= y, x > y, x = y, x <> y, 0 <= d < 10

Order tests (<> means 'not equals')

I believe ABC took it from Pascal, a language Guido began programming with.

It has now been removed in Python 3. Use != instead. If you are CRAZY you can scrap != and allow only <> in Py3K using this easter egg:

>>> from __future__ import barry_as_FLUFL
>>> 1 <> 2
True

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...