summaryrefslogtreecommitdiffstats
path: root/Doc/ref5.tex
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-03-17 15:59:52 (GMT)
committerGuido van Rossum <guido@python.org>1995-03-17 15:59:52 (GMT)
commit4dd6b84e5fafb53a678c7c6eeb50bba0f3ce800a (patch)
treec740223a126be0fa8153a3b9c03d79d5e20bcb53 /Doc/ref5.tex
parent55dd113bc878f5e584dcad81b4bed1144d320cb2 (diff)
downloadcpython-4dd6b84e5fafb53a678c7c6eeb50bba0f3ce800a.zip
cpython-4dd6b84e5fafb53a678c7c6eeb50bba0f3ce800a.tar.gz
cpython-4dd6b84e5fafb53a678c7c6eeb50bba0f3ce800a.tar.bz2
added table of precedences
Diffstat (limited to 'Doc/ref5.tex')
-rw-r--r--Doc/ref5.tex51
1 files changed, 51 insertions, 0 deletions
diff --git a/Doc/ref5.tex b/Doc/ref5.tex
index 3db2528..8f18c22 100644
--- a/Doc/ref5.tex
+++ b/Doc/ref5.tex
@@ -705,3 +705,54 @@ tuple, but rather yields the value of that expression (condition).
(To create an empty tuple, use an empty pair of parentheses:
\verb@()@.)
+
+\section{Summary}
+
+The following table summarizes the operator precedences in Python,
+from lowest precedence (least binding) to highest precedence (most
+binding). Operators in the same box have the same precedence. Unless
+the syntax is explicitly given, operators are binary. Operators in
+the same box group left to right (except for comparisons, which
+chain from left to right --- see above).
+
+\begin{center}
+\begin{tabular}{|c|c|}
+\hline
+\code{or} & Boolean OR \\
+\hline
+\code{and} & Boolean AND \\
+\hline
+\code{not} \var{x} & Boolean NOT \\
+\hline
+\code{in}, \code{not} \code{in} & Membership tests \\
+\code{is}, \code{is} \code{not} & Identity tests \\
+\code{<}, \code{<=}, \code{>}, \code{>=}, \code{<>}, \code{!=}, \code{=} &
+ Comparisons \\
+\hline
+\code{|} & Bitwise OR \\
+\hline
+\code{\^} & Bitwise XOR \\
+\hline
+\code{\&} & Bitwise AND \\
+\hline
+\code{<<}, \code{>>} & Shifts \\
+\hline
+\code{+}, \code{-} & Addition and subtraction \\
+\hline
+\code{*}, \code{/}, \code{\%} & Multiplication, division, remainder \\
+\hline
+\code{+\var{x}}, \code{-\var{x}} & Positive, negative \\
+\code{\~\var{x}} & Bitwise not \\
+\hline
+\code{\var{x}.\var{attribute}} & Attribute reference \\
+\code{\var{x}[\var{index}]} & Subscription \\
+\code{\var{x}[\var{index}:\var{index}]} & Slicing \\
+\code{\var{f}(\var{arguments}...)} & Function call \\
+\hline
+\code{(\var{expressions}\ldots)} & Binding or tuple display \\
+\code{[\var{expressions}\ldots]} & List display \\
+\code{\{\var{key}:\var{datum}\ldots\}} & Dictionary display \\
+\code{`\var{expression}\ldots`} & String conversion \\
+\hline
+\end{tabular}
+\end{center}