dketov
12/12/2011 - 12:22 PM

Операторы и инструкции

Операторы и инструкции

# -*- encoding: utf-8 -*-
"""
Инструкции
"""

a = 0
b = 1
c = 2
d = 3
e = 4
f = 5
g = 6

if a == b and c == d and   \
   d == e and f == g:
   print 'olde'                  # backslashes allow continuations

if (a == b and c == d and
    d == e and e == f):
    print 'new'                  # but parentheses usually do too

print "Here" 
# -*- encoding: utf-8 -*-
"""
Приоритет операторов
"""

#--+--------------------+------------------------
#  | Operator           |  Description
#--+--------------------+------------------------
#   lambda              | Lambda Expression
#   or                  | Boolean OR
#   and                 | Boolean AND
#   not x               | Boolean NOT
#   in, not in          | Membership tests
#   is, is not          | Identity tests
#   <, <=, >, >=, !=, ==| Comparisons
#   |                   | Bitwise OR
#   ^                   | Bitwise XOR
#   &                   | Bitwise AND
#   <<, >>              | Shifts
#   +, -                | Addition and subtraction
#   *, /, %             | Multiplication, Division and Remainder
#   +x, -x              | Positive, Negative
#   ~x                  | Bitwise NOT
#   **                  | Exponentiation
#   x.attribute         | Attribute reference
#   x[index]            | Subscription
#   x[index:index]      | Slicing
#   f(arguments ...)    | Function call
#   (expressions, ...)  | Binding or tuple display
#   [expressions, ...]  | List display
#   {key:datum, ...}    | Dictionary display
#   'expressions, ...   | String conversion