Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1156f623
Commit
1156f623
authored
Sep 19, 2000
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Many small clarifications, including many suggested by email.
parent
b96e0e5e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
17 deletions
+18
-17
Doc/ref/ref5.tex
Doc/ref/ref5.tex
+18
-17
No files found.
Doc/ref/ref5.tex
View file @
1156f623
...
...
@@ -676,11 +676,10 @@ converted to a common type.
\section
{
Comparisons
\label
{
comparisons
}}
\index
{
comparison
}
Contrary to
\C
, all comparison operations in Python have the same
priority, which is lower than that of any arithmetic, shifting or
bitwise operation. Also contrary to
\C
, expressions like
\code
{
a < b < c
}
have the interpretation that is conventional in
mathematics:
Unlike C, all comparison operations in Python have the same priority,
which is lower than that of any arithmetic, shifting or bitwise
operation. Also unlike C, expressions like
\code
{
a < b < c
}
have the
interpretation that is conventional in mathematics:
\indexii
{
C
}{
language
}
\begin{verbatim}
...
...
@@ -708,11 +707,12 @@ perfectly legal (though perhaps not pretty).
The forms
\code
{
<>
}
and
\code
{
!=
}
are equivalent; for consistency with
C,
\code
{
!=
}
is preferred; where
\code
{
!=
}
is mentioned below
\code
{
<>
}
is also accept
able. At some point in the (far) future,
\code
{
<>
}
may become obsolete
.
\code
{
<>
}
is also accept
ed. The
\code
{
<>
}
spelling is considered
obsolescent
.
The operators
\texttt
{
"<", ">", "==", ">=", "<="
}
, and
\texttt
{
"!="
}
compare
the values of two objects. The objects needn't have the same type.
The operators
\code
{
<
}
,
\code
{
>
}
,
\code
{
==
}
,
\code
{
>=
}
,
\code
{
<=
}
, and
\code
{
!=
}
compare
the values of two objects. The objects need not have the same type.
If both are numbers, they are coverted to a common type. Otherwise,
objects of different types
\emph
{
always
}
compare unequal, and are
ordered consistently but arbitrarily.
...
...
@@ -732,7 +732,8 @@ Numbers are compared arithmetically.
\item
Strings are compared lexicographically using the numeric equivalents
(the result of the built-in function
\function
{
ord()
}
) of their
characters.
characters. Unicode and 8-bit strings are fully interoperable in this
behavior.
\item
Tuples and lists are compared lexicographically using comparison of
...
...
@@ -765,19 +766,19 @@ For the list, tuple types, \code{\var{x} in \var{y}} is true if and only
if there exists such an index
\var
{
i
}
such that
\code
{
var
{
x
}
==
\var
{
y
}
[
\var
{
i
}
]
}
is true.
For the Unicode and string types,
\code
{
\var
{
x
}
in
\var
{
y
}}
is true if
and only
if there exists such an index
\var
{
i
}
such that
\
code
{
var
{
x
}
==
\var
{
y
}
[
\var
{
i
}
]
}
is true. If
\code
{
\var
{
x
}}
is not
a string of length
\code
{
1
}
or a unicode object of length
\code
{
1
}
,
a
\exception
{
TypeError
}
exception
is raised.
For the Unicode and string types,
\code
{
\var
{
x
}
in
\var
{
y
}}
is true if
and only if there exists an index
\var
{
i
}
such that
\code
{
\var
{
x
}
==
\
var
{
y
}
[
\var
{
i
}
]
}
is true. If
\code
{
\var
{
x
}}
is not a string or
Unicode object of length
\code
{
1
}
, a
\exception
{
TypeError
}
exception
is raised.
For user-defined classes which define the
\method
{__
contains
__
()
}
method,
\code
{
\var
{
x
}
in
\var
{
y
}}
is true if and only if
\code
{
\var
{
y
}
.
__
contains
__
(
\var
{
x
}
)
}
is true.
For user-defined classes which do not define
\method
{__
contains
__
()
}
and
do define
\
var
{__
getitem
__}
,
\code
{
\var
{
x
}
in
\var
{
y
}}
is true if and only
if there is a non-negative integer index
\var
{
i
}
such that
do define
\
method
{__
getitem
__
()
}
,
\code
{
\var
{
x
}
in
\var
{
y
}}
is true if
and only
if there is a non-negative integer index
\var
{
i
}
such that
\code
{
\var
{
x
}
==
\var
{
y
}
[
\var
{
i
}
]
}
, and all lower integer indices
do not raise
\exception
{
IndexError
}
exception. (If any other exception
is raised, it is as if
\keyword
{
in
}
raised that exception).
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment