Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="ref.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="ref.html" title='Python Reference Manual' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='index' href='genindex.html' title='Index' /> | |
10 | <link rel='last' href='about.html' title='About this document...' /> | |
11 | <link rel='help' href='about.html' title='About this document...' /> | |
12 | <link rel="prev" href="evalorder.html" /> | |
13 | <link rel="parent" href="expressions.html" /> | |
14 | <link rel="next" href="simple.html" /> | |
15 | <meta name='aesop' content='information' /> | |
16 | <title>5.14 Summary</title> | |
17 | </head> | |
18 | <body> | |
19 | <DIV CLASS="navigation"> | |
20 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
21 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
22 | <tr> | |
23 | <td class='online-navigation'><a rel="prev" title="5.13 Evaluation order" | |
24 | href="evalorder.html"><img src='../icons/previous.png' | |
25 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
26 | <td class='online-navigation'><a rel="parent" title="5. Expressions" | |
27 | href="expressions.html"><img src='../icons/up.png' | |
28 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
29 | <td class='online-navigation'><a rel="next" title="6. Simple statements" | |
30 | href="simple.html"><img src='../icons/next.png' | |
31 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
32 | <td align="center" width="100%">Python Reference Manual</td> | |
33 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
34 | href="contents.html"><img src='../icons/contents.png' | |
35 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
36 | <td class='online-navigation'><img src='../icons/blank.png' | |
37 | border='0' height='32' alt='' width='32' /></td> | |
38 | <td class='online-navigation'><a rel="index" title="Index" | |
39 | href="genindex.html"><img src='../icons/index.png' | |
40 | border='0' height='32' alt='Index' width='32' /></A></td> | |
41 | </tr></table> | |
42 | <div class='online-navigation'> | |
43 | <b class="navlabel">Previous:</b> | |
44 | <a class="sectref" rel="prev" href="evalorder.html">5.13 Evaluation order</A> | |
45 | <b class="navlabel">Up:</b> | |
46 | <a class="sectref" rel="parent" href="expressions.html">5. Expressions</A> | |
47 | <b class="navlabel">Next:</b> | |
48 | <a class="sectref" rel="next" href="simple.html">6. Simple statements</A> | |
49 | </div> | |
50 | <hr /></div> | |
51 | </DIV> | |
52 | <!--End of Navigation Panel--> | |
53 | ||
54 | <H1><A NAME="SECTION0071400000000000000000"></A><A NAME="summary"></A> | |
55 | <BR> | |
56 | 5.14 Summary | |
57 | </H1> | |
58 | ||
59 | <P> | |
60 | The following table summarizes the operator | |
61 | precedences<a id='l2h-450' xml:id='l2h-450'></a> in Python, from lowest | |
62 | precedence (least binding) to highest precedence (most binding). | |
63 | Operators in the same box have the same precedence. Unless the syntax | |
64 | is explicitly given, operators are binary. Operators in the same box | |
65 | group left to right (except for comparisons, including tests, which all | |
66 | have the same precedence and chain from left to right -- see section | |
67 | <A href="comparisons.html#comparisons">5.9</A> - and exponentiation, which groups from right to left). | |
68 | ||
69 | <P> | |
70 | <div class="center"><table class="realtable"> | |
71 | <thead> | |
72 | <tr> | |
73 | <th class="center">Operator</th> | |
74 | <th class="left" >Description</th> | |
75 | </tr> | |
76 | </thead> | |
77 | <tbody> | |
78 | <tr><td class="center" valign="baseline"><tt class="keyword">lambda</tt></td> | |
79 | <td class="left" >Lambda expression</td></tr> | |
80 | ||
81 | <tr><td class="center" valign="baseline"><tt class="keyword">or</tt></td> | |
82 | <td class="left" >Boolean OR</td></tr> | |
83 | ||
84 | <tr><td class="center" valign="baseline"><tt class="keyword">and</tt></td> | |
85 | <td class="left" >Boolean AND</td></tr> | |
86 | ||
87 | <tr><td class="center" valign="baseline"><tt class="keyword">not</tt> <var>x</var></td> | |
88 | <td class="left" >Boolean NOT</td></tr> | |
89 | ||
90 | <tr><td class="center" valign="baseline"><tt class="keyword">in</tt>, <tt class="keyword">not</tt> <tt class="keyword">in</tt></td> | |
91 | <td class="left" >Membership tests</td></tr> | |
92 | <tr><td class="center" valign="baseline"><tt class="keyword">is</tt>, <tt class="keyword">is not</tt></td> | |
93 | <td class="left" >Identity tests</td></tr> | |
94 | <tr><td class="center" valign="baseline"><code><</code>, <code><=</code>, <code>></code>, <code>>=</code>, | |
95 | <code><></code>, <code>!=</code>, <code>==</code></td> | |
96 | <td class="left" >Comparisons</td></tr> | |
97 | ||
98 | <tr><td class="center" valign="baseline"><code>|</code></td> | |
99 | <td class="left" >Bitwise OR</td></tr> | |
100 | ||
101 | <tr><td class="center" valign="baseline"><code>^</code></td> | |
102 | <td class="left" >Bitwise XOR</td></tr> | |
103 | ||
104 | <tr><td class="center" valign="baseline"><code>&</code></td> | |
105 | <td class="left" >Bitwise AND</td></tr> | |
106 | ||
107 | <tr><td class="center" valign="baseline"><code><</code><code><</code>, <code>></code><code>></code></td> | |
108 | <td class="left" >Shifts</td></tr> | |
109 | ||
110 | <tr><td class="center" valign="baseline"><code>+</code>, <code>-</code></td> | |
111 | <td class="left" >Addition and subtraction</td></tr> | |
112 | ||
113 | <tr><td class="center" valign="baseline"><code>*</code>, <code>/</code>, <code>%</code></td> | |
114 | <td class="left" >Multiplication, division, remainder</td></tr> | |
115 | ||
116 | <tr><td class="center" valign="baseline"><code>+<var>x</var></code>, <code>-<var>x</var></code></td> | |
117 | <td class="left" >Positive, negative</td></tr> | |
118 | <tr><td class="center" valign="baseline"><code>~<var>x</var></code></td> | |
119 | <td class="left" >Bitwise not</td></tr> | |
120 | ||
121 | <tr><td class="center" valign="baseline"><code>**</code></td> | |
122 | <td class="left" >Exponentiation</td></tr> | |
123 | ||
124 | <tr><td class="center" valign="baseline"><code><var>x</var>.<var>attribute</var></code></td> | |
125 | <td class="left" >Attribute reference</td></tr> | |
126 | <tr><td class="center" valign="baseline"><code><var>x</var>[<var>index</var>]</code></td> | |
127 | <td class="left" >Subscription</td></tr> | |
128 | <tr><td class="center" valign="baseline"><code><var>x</var>[<var>index</var>:<var>index</var>]</code></td> | |
129 | <td class="left" >Slicing</td></tr> | |
130 | <tr><td class="center" valign="baseline"><code><var>f</var>(<var>arguments</var>...)</code></td> | |
131 | <td class="left" >Function call</td></tr> | |
132 | ||
133 | <tr><td class="center" valign="baseline"><code>(<var>expressions</var>...)</code></td> | |
134 | <td class="left" >Binding or tuple display</td></tr> | |
135 | <tr><td class="center" valign="baseline"><code>[<var>expressions</var>...]</code></td> | |
136 | <td class="left" >List display</td></tr> | |
137 | <tr><td class="center" valign="baseline"><code>{<var>key</var>:<var>datum</var>...}</code></td> | |
138 | <td class="left" >Dictionary display</td></tr> | |
139 | <tr><td class="center" valign="baseline"><code>`<var>expressions</var>...`</code></td> | |
140 | <td class="left" >String conversion</td></tr></tbody> | |
141 | </table></div> | |
142 | ||
143 | <DIV CLASS="navigation"> | |
144 | <div class='online-navigation'> | |
145 | <p></p><hr /> | |
146 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
147 | <tr> | |
148 | <td class='online-navigation'><a rel="prev" title="5.13 Evaluation order" | |
149 | href="evalorder.html"><img src='../icons/previous.png' | |
150 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
151 | <td class='online-navigation'><a rel="parent" title="5. Expressions" | |
152 | href="expressions.html"><img src='../icons/up.png' | |
153 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
154 | <td class='online-navigation'><a rel="next" title="6. Simple statements" | |
155 | href="simple.html"><img src='../icons/next.png' | |
156 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
157 | <td align="center" width="100%">Python Reference Manual</td> | |
158 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
159 | href="contents.html"><img src='../icons/contents.png' | |
160 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
161 | <td class='online-navigation'><img src='../icons/blank.png' | |
162 | border='0' height='32' alt='' width='32' /></td> | |
163 | <td class='online-navigation'><a rel="index" title="Index" | |
164 | href="genindex.html"><img src='../icons/index.png' | |
165 | border='0' height='32' alt='Index' width='32' /></A></td> | |
166 | </tr></table> | |
167 | <div class='online-navigation'> | |
168 | <b class="navlabel">Previous:</b> | |
169 | <a class="sectref" rel="prev" href="evalorder.html">5.13 Evaluation order</A> | |
170 | <b class="navlabel">Up:</b> | |
171 | <a class="sectref" rel="parent" href="expressions.html">5. Expressions</A> | |
172 | <b class="navlabel">Next:</b> | |
173 | <a class="sectref" rel="next" href="simple.html">6. Simple statements</A> | |
174 | </div> | |
175 | </div> | |
176 | <hr /> | |
177 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
178 | </DIV> | |
179 | <!--End of Navigation Panel--> | |
180 | <ADDRESS> | |
181 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
182 | </ADDRESS> | |
183 | </BODY> | |
184 | </HTML> |