Python Operator Precedence

Source: Internet
Author: User
Tags bitwise

This table gives the operator precedence (from low to high) for Python.

From the lowest priority (the most loosely combined) to the highest priority (the most tightly coupled).

This means that in an expression, Python first calculates the following operator in the table, and then computes the operator that is listed in the upper part of the table.

Python Operator Precedence
operator Description
lambda Lambda expression
or Boolean "or"
and Boolean "and"
not x Boolean "Non"
in,not in Member Test
is,is not Identity testing
<,<=,>,>=,!=,== Comparison
| Bitwise OR
^ Bitwise XOR OR
& Bitwise-AND
<<,>> Shift
+,- Addition and subtraction
*,/,% Multiplication, division and redundancy
+x,-x PLUS sign
~x Rollover by bit
** Index
x.attribute Property Reference
x[index] Subscript
x[index:index] Addressing segment
f(arguments...) Function call
(experession,...) Binding or tuple display
[expression,...] List display
{key:datum,...} Dictionary display
‘expression,...‘ String conversions

Reprint: http://prayer163.blog.163.com/blog/static/29018857201301091850765/

Python Operator Precedence

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.