5. 표현식
*********

이 장은 파이썬에서 사용되는 표현식 요소들의 의미를 설명한다.

**문법 유의 사항:** 여기와 이어지는 장에서는, 구문 분석이 아니라 문법
을 설명하기 위해 확장 BNF 표기법을 사용한다. 문법 규칙이 다음과 같은
형태를 가지고,

   name ::= othername

뜻(semantics)을 주지 않으면, 이 형태의 "name" 의 뜻은 "othername" 과
같다.


5.1. 산술 변환
==============

When a description of an arithmetic operator below uses the phrase
"the numeric arguments are converted to a common type," the arguments
are coerced using the coercion rules listed at  Coercion rules.  If
both arguments are standard numeric types, the following coercions are
applied:

* 어느 한 인자가 복소수면 다른 하나는 복소수로 변환된다;

* 그렇지 않고, 어느 한 인자가 실수면, 다른 하나는 실수로 변환된다;

* otherwise, if either argument is a long integer, the other is
  converted to long integer;

* otherwise, both must be plain integers and no conversion is
  necessary.

Some additional rules apply for certain operators (e.g., a string left
argument to the '%' operator). Extensions can define their own
coercions.


5.2. 아톰 (Atoms)
=================

Atoms are the most basic elements of expressions.  The simplest atoms
are identifiers or literals.  Forms enclosed in reverse quotes or in
parentheses, brackets or braces are also categorized syntactically as
atoms.  The syntax for atoms is:

   atom      ::= identifier | literal | enclosure
   enclosure ::= parenth_form | list_display
                 | generator_expression | dict_display | set_display
                 | string_conversion | yield_atom


5.2.1. 식별자 (이름)
--------------------

아톰으로 등장하는 식별자는 이름이다. 구문 분석에 대해서는 식별자와 키
워드 섹션을, 이름과 연결에 대한 문서는 이름과 연결(binding) 섹션을 보
면 된다.

이름이 객체에 연결될 때, 아톰의 값을 구하면 객체가 나온다. 이름이 연결
되지 않았을 때, 값을 구하려고 하면 "NameError" 예외가 일어난다.

**비공개 이름 뒤섞기(private name mangling):** 클래스 정의에 등장하는
식별자가 두 개나 그 이상의 밑줄로 시작하고, 두 개나 그 이상의 밑줄로
끝나지 않으면, 그 클래스의 *비공개 이름(private name)* 으로 간주한다.
비공개 이름은 그 들을 위한 코드가 만들어지기 전에 더 긴 형태로 변환된
다. 이 변환은 그 이름의 앞에 클래스 이름을 삽입하는데, 클래스 이름의
처음에 오는 모든 밑줄을 제거한 후, 하나의 밑줄을 추가한다. 예를 들어,
"Ham" 이라는 이름의 클래스에 식별자 "__spam" 이 등장하면, "_Ham__spam"
으로 변환된다. 이 변환은 식별자가 사용되는 문법적인 문맥에 무관하다.
변환된 이름이 극단적으로 길면(255자보다 길면), 구현이 정의한 잘라내기
가 발생할 수 있다. 클래스 이름이 밑줄로만 구성되어 있으면, 변환은 일어
나지 않는다.


5.2.2. 리터럴 (Literals)
------------------------

Python supports string literals and various numeric literals:

   literal ::= stringliteral | integer | longinteger
               | floatnumber | imagnumber

Evaluation of a literal yields an object of the given type (string,
integer, long integer, floating point number, complex number) with the
given value.  The value may be approximated in the case of floating
point and imaginary (complex) literals.  See section 리터럴 for
details.

모든 리터럴은 불변 데이터형에 대응하기 때문에, 객체의 아이덴티티는 값
보다 덜 중요하다. 같은 값의 리터럴에 대해 반복적으로 값을 구하면 (프로
그램 텍스트의 같은 장소에 있거나 다른 장소에 있을 때) 같은 객체를 얻을
수도 있고, 같은 값의 다른 객체를 얻을 수도 있다.


5.2.3. 괄호 안에 넣은 형
------------------------

괄호 안에 넣은 형은, 괄호로 둘러싸인 생략 가능한 표현식 목록이다:

   parenth_form ::= "(" [expression_list] ")"

괄호 안에 넣은 표현식 목록은, 무엇이건 그 표현식 목록이 산출하는 것이
된다: 목록이 적어도 하나의 쉼표를 포함하면, 튜플이 된다; 그렇지 않으면
표현식 목록을 구성한 단일 표현식이 된다.

빈 괄호 쌍은 빈 튜플 객체를 만든다. 튜플은 불변이기 때문에 리터럴의 규
칙이 적용된다 (즉, 두 개의 빈 튜플은 같은 객체일 수도 있고 그렇지 않을
수도 있다).

튜플이 괄호에 의해 만들어지는 것이 아니라, 쉼표 연산자의 사용 때문이라
는 것에 주의해야 한다. 예외는 빈 튜플인데, 괄호가 필요하다 --- 표현식
에서 괄호 없는 "없음(nothing)"을 허락하는 것은 모호함을 유발하고 자주
발생하는 오타들이 잡히지 않은 채로 남게 할 것이다.


5.2.4. 리스트 디스플레이
------------------------

리스트 디스플레이는 꺾쇠괄호(square brackets)로 둘러싸인 표현식의 나열
인데 비어있을 수 있다:

   list_display        ::= "[" [expression_list | list_comprehension] "]"
   list_comprehension  ::= expression list_for
   list_for            ::= "for" target_list "in" old_expression_list [list_iter]
   old_expression_list ::= old_expression [("," old_expression)+ [","]]
   old_expression      ::= or_test | old_lambda_expr
   list_iter           ::= list_for | list_if
   list_if             ::= "if" old_expression [list_iter]

A list display yields a new list object.  Its contents are specified
by providing either a list of expressions or a list comprehension.
When a comma-separated list of expressions is supplied, its elements
are evaluated from left to right and placed into the list object in
that order.  When a list comprehension is supplied, it consists of a
single expression followed by at least one "for" clause and zero or
more "for" or "if" clauses.  In this case, the elements of the new
list are those that would be produced by considering each of the "for"
or "if" clauses a block, nesting from left to right, and evaluating
the expression to produce a list element each time the innermost block
is reached [1].


5.2.5. Displays for sets and dictionaries
-----------------------------------------

For constructing a set or a dictionary Python provides special syntax
called "displays", each of them in two flavors:

* 컨테이너의 내용을 명시적으로 나열하거나,

* 일련의 루프와 필터링 지시들을 통해 계산되는데, *컴프리헨션
  (comprehension)* 이라고 불린다.

컴프리헨션의 공통 문법 요소들은 이렇다:

   comprehension ::= expression comp_for
   comp_for      ::= "for" target_list "in" or_test [comp_iter]
   comp_iter     ::= comp_for | comp_if
   comp_if       ::= "if" expression_nocond [comp_iter]

컴프리헨션은 하나의 표현식과 그 뒤를 따르는 최소한 하나의 "for" 절과
없거나 여러 개의 "for" 또는 "if" 절로 구성된다. 이 경우, 새 컨테이너의
요소들은 각 "for" 또는 "if" 절이 왼쪽에서 오른쪽으로 중첩된 블록을 이
루고, 가장 안쪽에 있는 블록에서 표현식의 값을 구해서 만들어낸 것들이다
.

Note that the comprehension is executed in a separate scope, so names
assigned to in the target list don't "leak" in the enclosing scope.


5.2.6. 제너레이터 표현식 (Generator expressions)
------------------------------------------------

제너레이터 표현식은 괄호로 둘러싸인 간결한 제너레이터 표기법이다.

   generator_expression ::= "(" expression comp_for ")"

제너레이터 표현식은 새 제너레이터 객체를 만든다. 문법은 꺾쇠괄호나 중
괄호 대신 괄호로 둘러싸인다는 점만 제외하면 컴프리헨션과 같다.

Variables used in the generator expression are evaluated lazily when
the "__next__()" method is called for generator object (in the same
fashion as normal generators).  However, the leftmost "for" clause is
immediately evaluated, so that an error produced by it can be seen
before any other possible error in the code that handles the generator
expression.  Subsequent "for" clauses cannot be evaluated immediately
since they may depend on the previous "for" loop. For example: "(x*y
for x in range(10) for y in bar(x))".

The parentheses can be omitted on calls with only one argument.  See
section 호출 for the detail.


5.2.7. 딕셔너리 디스플레이
--------------------------

딕셔너리 디스플레이는 중괄호(curly braces)로 둘러싸인 키/데이터 쌍의
나열인데 비어있을 수 있다:

   dict_display       ::= "{" [key_datum_list | dict_comprehension] "}"
   key_datum_list     ::= key_datum ("," key_datum)* [","]
   key_datum          ::= expression ":" expression
   dict_comprehension ::= expression ":" expression comp_for

딕셔너리 디스플레이는 새 딕셔너리 객체를 만든다.

쉼표로 분리된 키/데이터 쌍의 시퀀스가 주어질 때, 그것들은 왼쪽에서 오
른쪽으로 값이 구해지고 딕셔너리의 엔트리들을 정의한다: 각 키 객체는 딕
셔너리에 대응하는 데이터를 저장하는 데 키로 사용된다. 이것은 키/값 목
록에서 같은 키를 여러 번 지정할 수 있다는 뜻인데, 그 키의 최종 딕셔너
리 값은 마지막에 주어진 것이 된다.

딕셔너리 컴프리헨션은, 리스트와 집합 컴프리헨션에 대비해서, 일반적인
"for" 와 "if" 절 앞에 콜론으로 분리된 두 개의 표현식을 필요로 한다. 컴
프리헨션이 실행될 때, 만들어지는 키와 값 요소들이 만들어지는 순서대로
딕셔너리에 삽입된다.

킷값의 형에 대한 제약은 앞의 섹션 표준형 계층 에서 나열되었다. (요약하
자면, 키 형은 *해시 가능* 해야 하는데, 모든 가변 객체들이 제외된다.)
중복된 키 간의 충돌은 감지되지 않는다; 주어진 키에 대해 저장된 마지막
(구문상으로 디스플레이의 가장 오른쪽에 있는) 데이터가 우선한다.


5.2.8. 집합 디스플레이
----------------------

집합 디스플레이는 중괄호(curly braces)로 표시되고, 키와 값을 분리하는
콜론(colon)이 없는 것으로 딕셔너리 디스플레이와 구분될 수 있다.

   set_display ::= "{" (expression_list | comprehension) "}"

집합 디스플레이는 새 가변 집합 객체를 만드는데, 그 내용은 표현식의 시
퀀스나 컴프리헨션으로 지정된다. 쉼표로 분리된 표현식의 목록이 제공될
때, 그 요소들은 왼쪽에서 오른쪽으로 값이 구해지고, 집합 객체에 더해진
다. 컴프리헨션이 제공될 때, 집합은 컴프리헨션으로 만들어지는 요소들로
구성된다.

빈 집합은 "{}" 으로 만들어질 수 없다; 이 리터럴은 빈 딕셔너리를 만든다
.


5.2.9. String conversions
-------------------------

A string conversion is an expression list enclosed in reverse (a.k.a.
backward) quotes:

   string_conversion ::= "`" expression_list "`"

A string conversion evaluates the contained expression list and
converts the resulting object into a string according to rules
specific to its type.

If the object is a string, a number, "None", or a tuple, list or
dictionary containing only objects whose type is one of these, the
resulting string is a valid Python expression which can be passed to
the built-in function "eval()" to yield an expression with the same
value (or an approximation, if floating point numbers are involved).

(In particular, converting a string adds quotes around it and converts
"funny" characters to escape sequences that are safe to print.)

Recursive objects (for example, lists or dictionaries that contain a
reference to themselves, directly or indirectly) use "..." to indicate
a recursive reference, and the result cannot be passed to "eval()" to
get an equal value ("SyntaxError" will be raised instead).

The built-in function "repr()" performs exactly the same conversion in
its argument as enclosing it in parentheses and reverse quotes does.
The built-in function "str()" performs a similar but more user-
friendly conversion.


5.2.10. 일드 표현식(Yield expressions)
--------------------------------------

   yield_atom       ::= "(" yield_expression ")"
   yield_expression ::= "yield" [expression_list]

버전 2.5에 추가.

The "yield" expression is only used when defining a generator
function, and can only be used in the body of a function definition.
Using a "yield" expression in a function definition is sufficient to
cause that definition to create a generator function instead of a
normal function.

When a generator function is called, it returns an iterator known as a
generator.  That generator then controls the execution of a generator
function. The execution starts when one of the generator's methods is
called.  At that time, the execution proceeds to the first "yield"
expression, where it is suspended again, returning the value of
"expression_list" to generator's caller.  By suspended we mean that
all local state is retained, including the current bindings of local
variables, the instruction pointer, and the internal evaluation stack.
When the execution is resumed by calling one of the generator's
methods, the function can proceed exactly as if the "yield" expression
was just another external call. The value of the "yield" expression
after resuming depends on the method which resumed the execution.

All of this makes generator functions quite similar to coroutines;
they yield multiple times, they have more than one entry point and
their execution can be suspended.  The only difference is that a
generator function cannot control where should the execution continue
after it yields; the control is always transferred to the generator's
caller.


5.2.10.1. 제너레이터-이터레이터 메서드
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

이 서브섹션은 제너레이터 이터레이터의 메서드들을 설명한다. 제너레이터
함수의 실행을 제어하는데 사용될 수 있다.

제너레이터가 이미 실행 중일 때 아래에 나오는 메서드들을 호출하면
"ValueError" 예외를 일으키는 것에 주의해야 한다.

generator.next()

   Starts the execution of a generator function or resumes it at the
   last executed "yield" expression.  When a generator function is
   resumed with a "next()" method, the current "yield" expression
   always evaluates to "None".  The execution then continues to the
   next "yield" expression, where the generator is suspended again,
   and the value of the "expression_list" is returned to "next()"'s
   caller. If the generator exits without yielding another value, a
   "StopIteration" exception is raised.

generator.send(value)

   Resumes the execution and "sends" a value into the generator
   function.  The "value" argument becomes the result of the current
   "yield" expression.  The "send()" method returns the next value
   yielded by the generator, or raises "StopIteration" if the
   generator exits without yielding another value. When "send()" is
   called to start the generator, it must be called with "None" as the
   argument, because there is no "yield" expression that could receive
   the value.

generator.throw(type[, value[, traceback]])

   Raises an exception of type "type" at the point where generator was
   paused, and returns the next value yielded by the generator
   function.  If the generator exits without yielding another value, a
   "StopIteration" exception is raised.  If the generator function
   does not catch the passed-in exception, or raises a different
   exception, then that exception propagates to the caller.

generator.close()

   Raises a "GeneratorExit" at the point where the generator function
   was paused.  If the generator function then raises "StopIteration"
   (by exiting normally, or due to already being closed) or
   "GeneratorExit" (by not catching the exception), close returns to
   its caller.  If the generator yields a value, a "RuntimeError" is
   raised.  If the generator raises any other exception, it is
   propagated to the caller.  "close()" does nothing if the generator
   has already exited due to an exception or normal exit.

여기에 제너레이터와 제너레이터 함수의 동작을 시연하는 간단한 예가 있다
:

   >>> def echo(value=None):
   ...     print "Execution starts when 'next()' is called for the first time."
   ...     try:
   ...         while True:
   ...             try:
   ...                 value = (yield value)
   ...             except Exception, e:
   ...                 value = e
   ...     finally:
   ...         print "Don't forget to clean up when 'close()' is called."
   ...
   >>> generator = echo(1)
   >>> print generator.next()
   Execution starts when 'next()' is called for the first time.
   1
   >>> print generator.next()
   None
   >>> print generator.send(2)
   2
   >>> generator.throw(TypeError, "spam")
   TypeError('spam',)
   >>> generator.close()
   Don't forget to clean up when 'close()' is called.

더 보기:

  **PEP 342** - 개선된 제너레이터를 통한 코루틴
     제너레이터의 API와 문법을 개선해서, 간단한 코루틴으로 사용할 수
     있도록 만드는 제안.


5.3. 프라이머리
===============

프라이머리는 언어에서 가장 강하게 결합하는 연산들을 나타낸다. 문법은
이렇다:

   primary ::= atom | attributeref | subscription | slicing | call


5.3.1. 어트리뷰트 참조
----------------------

어트리뷰트 참조는 마침표(period)와 이름이 뒤에 붙은 프라이머리다:

   attributeref ::= primary "." identifier

The primary must evaluate to an object of a type that supports
attribute references, e.g., a module, list, or an instance.  This
object is then asked to produce the attribute whose name is the
identifier.  If this attribute is not available, the exception
"AttributeError" is raised. Otherwise, the type and value of the
object produced is determined by the object.  Multiple evaluations of
the same attribute reference may yield different objects.


5.3.2. 서브스크립션(Subscriptions)
----------------------------------

서브스크립션은 시퀀스(문자열, 튜플, 리스트)나 매핑 (딕셔너리) 객체의
항목을 선택한다:

   subscription ::= primary "[" expression_list "]"

The primary must evaluate to an object of a sequence or mapping type.

프라이머리가 매핑이면, 표현식 목록은 값을 구했을 때 매핑의 키 중 하나
가 되어야 하고, 서브스크립션은 매핑에서 그 키에 대응하는 값을 선택한다
. (표현식 목록은 정확히 하나의 항목을 가지는 경우만을 제외하고는 튜플
이다.)

If the primary is a sequence, the expression list must evaluate to a
plain integer.  If this value is negative, the length of the sequence
is added to it (so that, e.g., "x[-1]" selects the last item of "x".)
The resulting value must be a nonnegative integer less than the number
of items in the sequence, and the subscription selects the item whose
index is that value (counting from zero).

문자열의 항목은 문자다. 문자는 별도의 데이터형이 아니고, 하나의 문자만
을 가진 문자열이다.


5.3.3. 슬라이싱(Slicings)
-------------------------

슬라이싱은 시퀀스 객체 (예를 들어, 문자열 튜플 리스트)에서 어떤 범위의
항목들을 선택한다. 슬라이싱은 표현식이나 대입의 타깃이나 "del" 문에 사
용될 수 있다. 슬라이싱의 문법은 이렇다:

   slicing          ::= simple_slicing | extended_slicing
   simple_slicing   ::= primary "[" short_slice "]"
   extended_slicing ::= primary "[" slice_list "]"
   slice_list       ::= slice_item ("," slice_item)* [","]
   slice_item       ::= expression | proper_slice | ellipsis
   proper_slice     ::= short_slice | long_slice
   short_slice      ::= [lower_bound] ":" [upper_bound]
   long_slice       ::= short_slice ":" [stride]
   lower_bound      ::= expression
   upper_bound      ::= expression
   stride           ::= expression
   ellipsis         ::= "..."

There is ambiguity in the formal syntax here: anything that looks like
an expression list also looks like a slice list, so any subscription
can be interpreted as a slicing.  Rather than further complicating the
syntax, this is disambiguated by defining that in this case the
interpretation as a subscription takes priority over the
interpretation as a slicing (this is the case if the slice list
contains no proper slice nor ellipses).  Similarly, when the slice
list has exactly one short slice and no trailing comma, the
interpretation as a simple slicing takes priority over that as an
extended slicing.

The semantics for a simple slicing are as follows.  The primary must
evaluate to a sequence object.  The lower and upper bound expressions,
if present, must evaluate to plain integers; defaults are zero and the
"sys.maxint", respectively.  If either bound is negative, the
sequence's length is added to it.  The slicing now selects all items
with index *k* such that "i <= k < j" where *i* and *j* are the
specified lower and upper bounds.  This may be an empty sequence.  It
is not an error if *i* or *j* lie outside the range of valid indexes
(such items don't exist so they aren't selected).

The semantics for an extended slicing are as follows.  The primary
must evaluate to a mapping object, and it is indexed with a key that
is constructed from the slice list, as follows.  If the slice list
contains at least one comma, the key is a tuple containing the
conversion of the slice items; otherwise, the conversion of the lone
slice item is the key.  The conversion of a slice item that is an
expression is that expression.  The conversion of an ellipsis slice
item is the built-in "Ellipsis" object.  The conversion of a proper
slice is a slice object (see section 표준형 계층) whose "start",
"stop" and "step" attributes are the values of the expressions given
as lower bound, upper bound and stride, respectively, substituting
"None" for missing expressions.


5.3.4. 호출
-----------

호출은 콜러블 객체 (예를 들어, *함수*) 를 빌 수도 있는 *인자* 들의 목
록으로 호출한다.

   call                 ::= primary "(" [argument_list [","]
            | expression genexpr_for] ")"
   argument_list        ::= positional_arguments ["," keyword_arguments]
                       ["," "*" expression] ["," keyword_arguments]
                       ["," "**" expression]
                     | keyword_arguments ["," "*" expression]
                       ["," "**" expression]
                     | "*" expression ["," keyword_arguments] ["," "**" expression]
                     | "**" expression
   positional_arguments ::= expression ("," expression)*
   keyword_arguments    ::= keyword_item ("," keyword_item)*
   keyword_item         ::= identifier "=" expression

A trailing comma may be present after the positional and keyword
arguments but does not affect the semantics.

The primary must evaluate to a callable object (user-defined
functions, built-in functions, methods of built-in objects, class
objects, methods of class instances, and certain class instances
themselves are callable; extensions may define additional callable
object types).  All argument expressions are evaluated before the call
is attempted.  Please refer to section 함수 정의 for the syntax of
formal *parameter* lists.

키워드 인자가 있으면, 먼저 다음과 같이 위치 인자로 변환된다. 먼저 형식
파라미터들의 채워지지 않은 슬롯들의 목록이 만들어진다. N 개의 위치 인
자들이 있다면, 처음 N 개의 슬롯에 넣는다. 그다음, 각 키워드 인자마다,
식별자가 대응하는 슬롯을 결정하는 데 사용된다 (식별자가 첫 번째 형식
파라미터의 이름과 같으면, 첫 번째 슬롯은 사용되고, 이런 식으로 계속한
다). 슬롯이 이미 채워졌으면, "TypeError" 예외를 일으킨다. 그렇지 않으
면 그 인자의 값을 슬롯에 채워 넣는다 (표현식이 "None" 이라 할지라도,
슬롯을 채우게 된다). 모든 인자가 처리되었을 때, 아직 채워지지 않은 슬
롯들을 함수 정의로부터 오는 대응하는 기본값들로 채운다. (기본값들은 함
수가 정의될 때 한 번만 값을 구한다; 그래서, 리스트나 딕셔너리 같은 가
변객체들이 기본값으로 사용되면 해당 슬롯에 인자값을 지정하지 않은 모든
호출에서 공유된다; 보통 이런 상황은 피해야 할 일이다.) 만약 기본값이
지정되지 않고, 아직도 비어있는 슬롯이 남아있다면, "TypeError" 예외가
발생한다. 그렇지 않으면, 채워진 슬롯의 목록이 호출의 인자 목록으로 사
용된다.

구현은 위치 파라미터가 이름을 갖지 않아서, 설사 문서화의 목적으로 이름
이 붙여졌다 하더라도, 키워드로 공급될 수 없는 내장 함수들을 제공할 수
있다. CPython 에서, 인자들을 파싱하기 위해 "PyArg_ParseTuple()" 를 사
용하는 C로 구현된 함수들이 이 경우다.

형식 파라미터 슬롯들보다 많은 위치 인자들이 있으면, "*identifier" 문법
을 사용하는 형식 파라미터가 있지 않은 한, "TypeError" 예외를 일으킨다;
이 경우, 그 형식 파라미터는 남는 위치 인자들을 포함하는 튜플을 전달받
는다 (또는 남는 위치 인자들이 없으면 빈 튜플).

키워드 인자가 형식 파라미터 이름에 대응하지 않으면, "**identifier" 문
법을 사용하는 형식 파라미터가 있지 않은 한, "TypeError" 예외를 일으킨
다; 이 경우, 그 형식 파라미터는 남는 키워드 인자들을 포함하는 딕셔너리
나, 남는 위치기반 인자들이 없으면 빈 (새) 딕셔너리를 전달받는다.

If the syntax "*expression" appears in the function call, "expression"
must evaluate to an iterable.  Elements from this iterable are treated
as if they were additional positional arguments; if there are
positional arguments *x1*, ..., *xN*, and "expression" evaluates to a
sequence *y1*, ..., *yM*, this is equivalent to a call with M+N
positional arguments *x1*, ..., *xN*, *y1*, ..., *yM*.

A consequence of this is that although the "*expression" syntax may
appear *after* some keyword arguments, it is processed *before* the
keyword arguments (and the "**expression" argument, if any -- see
below).  So:

   >>> def f(a, b):
   ...     print a, b
   ...
   >>> f(b=1, *(2,))
   2 1
   >>> f(a=1, *(2,))
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   TypeError: f() got multiple values for keyword argument 'a'
   >>> f(1, *(2,))
   1 2

같은 호출에서 키워드 인자와 "*expression" 문법을 모두 사용하는 것은 일
반적이지 않기 때문에, 실제로는 이런 혼란이 일어나지 않는다.

If the syntax "**expression" appears in the function call,
"expression" must evaluate to a mapping, the contents of which are
treated as additional keyword arguments.  In the case of a keyword
appearing in both "expression" and as an explicit keyword argument, a
"TypeError" exception is raised.

Formal parameters using the syntax "*identifier" or "**identifier"
cannot be used as positional argument slots or as keyword argument
names.  Formal parameters using the syntax "(sublist)" cannot be used
as keyword argument names; the outermost sublist corresponds to a
single unnamed argument slot, and the argument value is assigned to
the sublist using the usual tuple assignment rules after all other
parameter processing is done.

호출은 예외를 일으키지 않는 한, 항상 어떤 값을 돌려준다, "None" 일 수
있다. 이 값이 어떻게 계산되는지는 콜러블 객체의 형에 달려있다.

만약 그것이---

사용자 정의 함수면:
   인자 목록을 전달해서 함수의 코드 블록이 실행된다. 코드 블록이 처음
   으로 하는 일은 형식 파라미터들을 인자에 결합하는 것이다; 이것은 섹
   션 함수 정의 에서 설명한다. 코드 블록이 "return" 문을 실행하면, 함
   수 호출의 반환 값을 지정하게 된다.

내장 함수나 메서드면:
   결과는 인터프리터에 달려있다; 내장 함수와 메서드들에 대한 설명은 내
   장 함수 를 보면 된다.

클래스 객체면:
   그 클래스의 새 인스턴스가 반환된다.

클래스 인스턴스 메서드면:
   대응하는 사용자 정의 함수가 호출되는데, 그 인스턴스가 첫 번째 인자
   가 되는 하나만큼 더 긴 인자 목록이 전달된다.

클래스 인스턴스면:
   그 클래스는 "__call__()" 메서드를 정의해야 한다; 그 효과는 그 메서
   드가 호출되는 것과 같다.


5.4. 거듭제곱 연산자
====================

거듭제곱 연산자는 그것의 왼쪽에 붙는 일 항 연산자보다 더 강하게 결합한
다; 그것의 오른쪽에 붙는 일 항 연산자보다는 약하게 결합한다. 문법은 이
렇다:

   power ::= primary ["**" u_expr]

그래서, 괄호가 없는 거듭제곱과 일 항 연산자의 시퀀스에서, 연산자는 오
른쪽에서 왼쪽으로 값이 구해진다 (이것이 피연산자의 값을 구하는 순서를
제약하는 것은 아니다): "-1**2" 은 "-1" 이 된다.

The power operator has the same semantics as the built-in "pow()"
function, when called with two arguments: it yields its left argument
raised to the power of its right argument.  The numeric arguments are
first converted to a common type.  The result type is that of the
arguments after coercion.

With mixed operand types, the coercion rules for binary arithmetic
operators apply. For int and long int operands, the result has the
same type as the operands (after coercion) unless the second argument
is negative; in that case, all arguments are converted to float and a
float result is delivered. For example, "10**2" returns "100", but
"10**-2" returns "0.01". (This last feature was added in Python 2.2.
In Python 2.1 and before, if both arguments were of integer types and
the second argument was negative, an exception was raised).

Raising "0.0" to a negative power results in a "ZeroDivisionError".
Raising a negative number to a fractional power results in a
"ValueError".


5.5. 일 항 산술과 비트 연산
===========================

모든 일 항 산술과 비트 연산자는 같은 우선순위를 갖는다.

   u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr

일 항 "-" (마이너스) 연산자는 그 숫자 인자의 음의 값을 준다.

일 항 "+" (플러스) 연산자는 그 숫자 인자의 값을 변경 없이 준다.

The unary "~" (invert) operator yields the bitwise inversion of its
plain or long integer argument.  The bitwise inversion of "x" is
defined as "-(x+1)".  It only applies to integral numbers.

세 가지 경우 모두, 인자가 올바른 형을 갖지 않는다면, "TypeError" 예외
가 발생한다.


5.6. 이항 산술 연산
===================

이항 산술 연산자는 관습적인 우선순위를 갖는다. 이 연산자 중 일부는 일
부 비 숫자 형에도 적용됨에 주의해야 한다. 거듭제곱 연산자와는 별개로,
오직 두 가지 수준만 있는데, 하나는 곱셈형 연산자들이고, 하나는 덧셈형
연산자들이다.

   m_expr ::= u_expr | m_expr "*" u_expr | m_expr "//" u_expr | m_expr "/" u_expr
              | m_expr "%" u_expr
   a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr

The "*" (multiplication) operator yields the product of its arguments.
The arguments must either both be numbers, or one argument must be an
integer (plain or long) and the other must be a sequence. In the
former case, the numbers are converted to a common type and then
multiplied together.  In the latter case, sequence repetition is
performed; a negative repetition factor yields an empty sequence.

The "/" (division) and "//" (floor division) operators yield the
quotient of their arguments.  The numeric arguments are first
converted to a common type. Plain or long integer division yields an
integer of the same type; the result is that of mathematical division
with the 'floor' function applied to the result. Division by zero
raises the "ZeroDivisionError" exception.

"%" (모듈로, modulo) 연산자는 첫 번째 인자를 두 번째 인자로 나눈 나머
지를 준다. 숫자 인자들은 먼저 공통형으로 변환된다. 오른쪽 인자가 0이면
"ZeroDivisionError" 예외를 일으킨다. 인자들은 실수가 될 수 있다, 예를
들어, "3.14%0.7" 는 "0.34" 와 같다 ("3.14" 가 "4*0.7 + 0.34" 와 같으므
로.) 모듈로 연산자는 항상 두 번째 피연산자와 같은 부호를 갖는 결과를
준다 (또는 0이다); 결과의 절댓값은 두 번째 피연산자의 절댓값보다 작다
[2].

The integer division and modulo operators are connected by the
following identity: "x == (x/y)*y + (x%y)".  Integer division and
modulo are also connected with the built-in function "divmod()":
"divmod(x, y) == (x/y, x%y)".  These identities don't hold for
floating point numbers; there similar identities hold approximately
where "x/y" is replaced by "floor(x/y)" or "floor(x/y) - 1" [3].

In addition to performing the modulo operation on numbers, the "%"
operator is also overloaded by string and unicode objects to perform
string formatting (also known as interpolation). The syntax for string
formatting is described in the Python Library Reference, section
String Formatting Operations.

버전 2.3 폐지: The floor division operator, the modulo operator, and
the "divmod()" function are no longer defined for complex numbers.
Instead, convert to a floating point number using the "abs()" function
if appropriate.

The "+" (addition) operator yields the sum of its arguments. The
arguments must either both be numbers or both sequences of the same
type.  In the former case, the numbers are converted to a common type
and then added together.  In the latter case, the sequences are
concatenated.

"-" (빼기) 연산자는 그 인자들의 차를 준다. 숫자 인자들은 먼저 공통형으
로 변환된다.


5.7. 시프트 연산
================

시프트 연산은 산술 연산보다 낮은 우선순위를 갖는다.

   shift_expr ::= a_expr | shift_expr ( "<<" | ">>" ) a_expr

These operators accept plain or long integers as arguments.  The
arguments are converted to a common type.  They shift the first
argument to the left or right by the number of bits given by the
second argument.

A right shift by *n* bits is defined as division by "pow(2, n)".  A
left shift by *n* bits is defined as multiplication with "pow(2, n)".
Negative shift counts raise a "ValueError" exception.

주석: 현재 구현에서, 우측 피연산자는 최대 "sys.maxsize" 일 것이 요구
  된다. 우측 피연산자가 "sys.maxsize" 보다 크면 "OverflowError" 예외가
  발생 한다.


5.8. 이항 비트 연산
===================

세 개의 비트 연산은 각기 다른 우선순위를 갖는다:

   and_expr ::= shift_expr | and_expr "&" shift_expr
   xor_expr ::= and_expr | xor_expr "^" and_expr
   or_expr  ::= xor_expr | or_expr "|" xor_expr

The "&" operator yields the bitwise AND of its arguments, which must
be plain or long integers.  The arguments are converted to a common
type.

The "^" operator yields the bitwise XOR (exclusive OR) of its
arguments, which must be plain or long integers.  The arguments are
converted to a common type.

The "|" operator yields the bitwise (inclusive) OR of its arguments,
which must be plain or long integers.  The arguments are converted to
a common type.


5.9. 비교
=========

C와는 달리, 파이썬에서 모든 비교 연산은 같은 우선순위를 갖는데, 산술,
시프팅, 비트 연산들보다 낮다. 또한, C와는 달리, "a < b < c" 와 같은 표
현식이 수학에서와 같은 방식으로 해석된다.

   comparison    ::= or_expr ( comp_operator or_expr )*
   comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "<>" | "!="
                     | "is" ["not"] | ["not"] "in"

비교는 논리값을 준다: "True" 또는 "False"

비교는 자유롭게 연결될 수 있다, 예를 들어, "x < y <= z" 는 "x < y and
y <= z" 와 동등한데, 차이점은 "y" 의 값을 오직 한 번만 구한다는 것이다
(하지만 두 경우 모두 "x < y" 가 거짓이면 "z" 의 값은 구하지 않는다).

형식적으로, *a*, *b*, *c*, ..., *y*, *z* 가 표현식이고, *op1*, *op2*,
..., *opN* 가 비교 연산자면, "a op1 b op2 c ... y opN z" 는 각 표현식
의 값을 최대 한 번만 구한다는 점을 제외하고는 "a op1 b and b op2 c and
... y opN z" 와 동등하다.

"a op1 b op2 c" 가 *a* 와 *c* 간의 어떤 종류의 비교도 암시하지 않기 때
문에, 예를 들어, "x < y > z" 이 완벽하게 (아마 이쁘지는 않더라도) 올바
르다는 것에 주의해야 한다.

The forms "<>" and "!=" are equivalent; for consistency with C, "!="
is preferred; where "!=" is mentioned below "<>" is also accepted.
The "<>" spelling is considered obsolescent.


5.9.1. 값 비교
--------------

연산자 "<", ">", "==", ">=", "<=", "!=" 는 두 객체의 값을 비교한다. 객
체들이 같은 형일 필요는 없다.

객체, 값, 형 장은 객체들이 (형과 아이덴티티에 더해) 값을 갖는다고 말하
고 있다. 파이썬에서 객체의 값은 좀 추상적인 개념이다: 예를 들어, 객체
의 값에 대한 규범적인(canonical) 액세스 방법은 없다. 또한, 객체의 값이
특별한 방식(예를 들어, 모든 데이터 어트리뷰트로 구성되는 것)으로 구성
되어야 한다는 요구 사항도 없다. 비교 연산자는 객체의 값이 무엇인지에
대한 특정한 종류의 개념을 구현한다. 객체의 값을 비교를 통해 간접적으로
정의한다고 생각해도 좋다.

Types can customize their comparison behavior by implementing a
"__cmp__()" method or *rich comparison methods* like "__lt__()",
described in 기본적인 커스터마이제이션.

동등 비교 ("==" 와 "!=") 의 기본 동작은 객체의 아이덴티티에 기반을 둔
다. 그래서, 같은 아이덴티티를 갖는 인스턴스 간의 동등 비교는 같음을 주
고, 다른 아이덴티티를 갖는 인스턴스 간의 동등 비교는 다름을 준다. 이
기본 동작의 동기는 모든 객체가 반사적(reflexive) (즉, "x is y" 는 "x
== y" 를 암시한다) 이도록 만들고자 하는 욕구다.

The default order comparison ("<", ">", "<=", and ">=") gives a
consistent but arbitrary order.

(This unusual definition of comparison was used to simplify the
definition of operations like sorting and the "in" and "not in"
operators. In the future, the comparison rules for objects of
different types are likely to change.)

다른 아이덴티티를 갖는 인스턴스들이 항상 서로 다르다는, 기본 동등 비교
의 동작은, 객체의 값과 값 기반의 동등함에 대한 나름의 정의를 가진 형들
이 필요로 하는 것과는 크게 다를 수 있다. 그런 형들은 자신의 비교 동작
을 커스터마이즈 할 필요가 있고, 사실 많은 내장형이 그렇게 하고 있다.

다음 목록은 가장 중요한 내장형들의 비교 동작을 기술한다.

* 내장 숫자 형 ((Numeric Types --- int, float, long, complex)) 과 표
  준 라이브러리 형 "fractions.Fraction" 과 "decimal.Decimal" 에 속하는
  숫 자들은, 복소수가 대소 비교를 지원하지 않는다는 제약 사항만 빼고는
  , 같거나 다른 형들 간의 비교가 가능하다. 관련된 형들의 한계 안에서,
  정 밀도의 손실 없이 수학적으로 (알고리즘 적으로) 올바르게 비교한다.

* Strings (instances of "str" or "unicode") compare
  lexicographically using the numeric equivalents (the result of the
  built-in function "ord()") of their characters. [4] When comparing
  an 8-bit string and a Unicode string, the 8-bit string is converted
  to Unicode.  If the conversion fails, the strings are considered
  unequal.

* Instances of "tuple" or "list" can be compared only within each of
  their types.  Equality comparison across these types results in
  unequality, and ordering comparison across these types gives an
  arbitrary order.

  These sequences compare lexicographically using comparison of
  corresponding elements, whereby reflexivity of the elements is
  enforced.

  In enforcing reflexivity of elements, the comparison of collections
  assumes that for a collection element "x", "x == x" is always true.
  Based on that assumption, element identity is compared first, and
  element comparison is performed only for distinct elements.  This
  approach yields the same result as a strict element comparison
  would, if the compared elements are reflexive.  For non-reflexive
  elements, the result is different than for strict element
  comparison.

  내장 컬렉션들의 사전적인 비교는 다음과 같이 이루어진다:

  * 두 컬렉션이 같다고 비교되기 위해서는, 같은 형이고, 길이가 같고,
    대 응하는 요소들의 각 쌍이 같다고 비교되어야 한다 (예를 들어,
    "[1,2] == (1,2)" 는 거짓인데, 형이 다르기 때문이다).

  * Collections are ordered the same as their first unequal elements
    (for example, "cmp([1,2,x], [1,2,y])" returns the same as
    "cmp(x,y)").  If a corresponding element does not exist, the
    shorter collection is ordered first (for example, "[1,2] <
    [1,2,3]" is true).

* 매핑들 ("dict" 의 인스턴스들) 은 같은 *(key, value)* 쌍들을 가질
  때, 그리고 오직 이 경우만 같다고 비교된다. 키와 값의 동등 비교는 반
  사성 을 강제한다.

  Outcomes other than equality are resolved consistently, but are not
  otherwise defined. [5]

* Most other objects of built-in types compare unequal unless they
  are the same object; the choice whether one object is considered
  smaller or larger than another one is made arbitrarily but
  consistently within one execution of a program.

비교 동작을 커스터마이즈하는 사용자 정의 클래스들은 가능하다면 몇 가지
일관성 규칙을 준수해야 한다:

* 동등 비교는 반사적(reflexive)이어야 한다. 다른 말로 표현하면, 아이
  덴 티티가 같은 객체는 같다고 비교되어야 한다:

     "x is y" 면 "x == y" 다.

* 비교는 대칭적(symmetric)이어야 한다. 다른 말로 표현하면, 다음과 같
  은 표현식은 같은 결과를 주어야 한다:

     "x == y" 와 "y == x"

     "x != y" 와 "y != x"

     "x < y" 와 "y > x"

     "x <= y" 와 "y >= x"

* 비교는 추이적(transitive)이어야 한다. 다음 (철저하지 않은) 예들이
  이 것을 예증한다:

     "x > y and y > z" 면 "x > z" 다

     x < y and y <= z`` 면 "x < z" 다

* 역 비교는 논리적 부정이 되어야 한다. 다른 말로 표현하면, 다음 표현
  식 들이 같은 값을 주어야 한다:

     "x == y" 와 "not x != y"

     "x < y" 와 "not x >= y" (전 순서의 경우)

     "x > y" 와 "not x <= y" (전 순서의 경우)

  마지막 두 표현식은 전 순서 컬렉션에 적용된다 (예를 들어, 시퀀스에는
  적용되지만, 집합과 매핑은 그렇지 않다). "total_ordering()" 데코레이
  터 또한 보기 바란다.

* "hash()" 결과는 동등성과 일관성을 유지해야 한다. 같은 객체들은 같
  은 해시값을 같거나 해시 불가능으로 지정되어야 한다.

Python does not enforce these consistency rules.


5.9.2. 멤버십 검사 연산
-----------------------

연산자 "in" 과 "not in" 은 멤버십을 검사한다. "x in s" 는 *x* 가 *s*
의 멤버일 때 "True" 를, 그렇지 않을 때 "False" 를 준다. "x not in s"
은 "x in s" 의 부정을 준다. 딕셔너리 뿐만 아니라 모든 내장 시퀀스들과
집합 형들이 이것을 지원하는데, 딕셔너리의 경우는 "in" 이 딕셔너리에 주
어진 키가 있는지 검사한다. list, tuple, set, frozenset, dict,
collections.deque 와 같은 컨테이너형들의 경우, 표현식 "x in y" 는
"any(x is e or x == e for e in y)" 와 동등하다.

문자열과 바이트열 형의 경우, "x in y" 는 *x* 가 *y* 의 서브 스트링
(substring)인 경우, 그리고 오직 그 경우만 "True" 다. 동등한 검사는
"y.find(x) != -1" 다. 빈 문자열은 항상 다른 문자열들의 서브 스트링으로
취급되기 때문에, """ in "abc"" 은 "True" 를 돌려준다.

"__contains__()" 메서드를 정의하는 사용자 정의 클래스의 경우, "x in y"
는 "y.__contains__(x)" 가 참을 줄 때 "True" 를, 그렇지 않으면 "False"
를 돌려준다.

"__contains__()" 를 정의하지 않지만 "__iter__()" 를 정의하는 사용자 정
의 클래스의 경우, "x in y" 는 "y" 를 탐색할 때 "x == z" 를 만족하는 어
떤 값 "z" 가 만들어지면 "True" 다. 탐색하는 동안 예외가 발생하면 "in"
이 그 예외를 일으킨 것으로 취급된다.

Lastly, the old-style iteration protocol is tried: if a class defines
"__getitem__()", "x in y" is "True" if and only if there is a non-
negative integer index *i* such that "x == y[i]", and all lower
integer indices do not raise "IndexError" exception. (If any other
exception is raised, it is as if "in" raised that exception).

연산자 "not in" 은 "in" 의 논리적 부정으로 정의된다.


5.9.3. 아이덴티티 비교
----------------------

The operators "is" and "is not" test for object identity: "x is y" is
true if and only if *x* and *y* are the same object.  "x is not y"
yields the inverse truth value. [6]


5.10. 논리 연산(Boolean operations)
===================================

   or_test  ::= and_test | or_test "or" and_test
   and_test ::= not_test | and_test "and" not_test
   not_test ::= comparison | "not" not_test

In the context of Boolean operations, and also when expressions are
used by control flow statements, the following values are interpreted
as false: "False", "None", numeric zero of all types, and empty
strings and containers (including strings, tuples, lists,
dictionaries, sets and frozensets).  All other values are interpreted
as true.  (See the "__nonzero__()" special method for a way to change
this.)

연산자 "not" 은 그 인자가 거짓이면 "True" 를, 그렇지 않으면 "False" 를
준다.

표현식 "x and y" 는 먼저 *x* 의 값을 구한다; *x* 가 거짓이면 그 값을
돌려준다; 그렇지 않으면 *y* 의 값을 구한 후에 그 결과를 돌려준다.

표현식 "x or y" 는 먼저 *x* 의 값을 구한다; *x* 가 참이면 그 값을 돌려
준다. 그렇지 않으면 *y* 의 값을 구한 후에 그 결과를 돌려준다.

(Note that neither "and" nor "or" restrict the value and type they
return to "False" and "True", but rather return the last evaluated
argument. This is sometimes useful, e.g., if "s" is a string that
should be replaced by a default value if it is empty, the expression
"s or 'foo'" yields the desired value.  Because "not" has to invent a
value anyway, it does not bother to return a value of the same type as
its argument, so e.g., "not 'foo'" yields "False", not "''".)


5.11. Conditional Expressions
=============================

버전 2.5에 추가.

   conditional_expression ::= or_test ["if" or_test "else" expression]
   expression             ::= conditional_expression | lambda_expr

조건 표현식은 (때로 "삼 항 연산자(ternary operator)"라고 불린다) 모든
파이썬 연산에서 가장 낮은 우선순위를 갖는다.

The expression "x if C else y" first evaluates the condition, *C*
(*not* *x*); if *C* is true, *x* is evaluated and its value is
returned; otherwise, *y* is evaluated and its value is returned.

조건 표현식에 대한 더 자세한 내용은 **PEP 308** 를 참고하라.


5.12. 람다(Lambdas)
===================

   lambda_expr     ::= "lambda" [parameter_list]: expression
   old_lambda_expr ::= "lambda" [parameter_list]: old_expression

Lambda expressions (sometimes called lambda forms) have the same
syntactic position as expressions.  They are a shorthand to create
anonymous functions; the expression "lambda parameters: expression"
yields a function object.  The unnamed object behaves like a function
object defined with

   def <lambda>(parameters):
       return expression

See section 함수 정의 for the syntax of parameter lists.  Note that
functions created with lambda expressions cannot contain statements.


5.13. 표현식 목록(Expression lists)
===================================

   expression_list ::= expression ( "," expression )* [","]

An expression list containing at least one comma yields a tuple.  The
length of the tuple is the number of expressions in the list.  The
expressions are evaluated from left to right.

끝에 붙는 쉼표는 단일 튜플(single tuple) (소위, *싱글톤(singleton)*)
을 만들 때만 필수다; 다른 모든 경우에는 생략할 수 있다. 끝에 붙는 쉼표
가 없는 단일 표현식은 튜플을 만들지 않고, 그 표현식의 값을 준다. (빈
튜플을 만들려면, 빈 괄호 쌍을 사용하라: "()".)


5.14. 값을 구하는 순서
======================

Python evaluates expressions from left to right. Notice that while
evaluating an assignment, the right-hand side is evaluated before the
left-hand side.

다 줄들에서, 표현식은 그들의 끝에 붙은 숫자들의 순서대로 값이 구해진다
:

   expr1, expr2, expr3, expr4
   (expr1, expr2, expr3, expr4)
   {expr1: expr2, expr3: expr4}
   expr1 + expr2 * (expr3 - expr4)
   expr1(expr2, expr3, *expr4, **expr5)
   expr3, expr4 = expr1, expr2


5.15. 연산자 우선순위
=====================

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, including
tests, which all have the same precedence and chain from left to right
--- see section 비교 --- and exponentiation, which groups from right
to left).

+-------------------------------------------------+---------------------------------------+
| 연산자                                          | 설명                                  |
+=================================================+=======================================+
| "lambda"                                        | 람다 표현식                           |
+-------------------------------------------------+---------------------------------------+
| "if" -- "else"                                  | 조건 표현식                           |
+-------------------------------------------------+---------------------------------------+
| "or"                                            | 논리 OR                               |
+-------------------------------------------------+---------------------------------------+
| "and"                                           | 논리 AND                              |
+-------------------------------------------------+---------------------------------------+
| "not" "x"                                       | 논리 NOT                              |
+-------------------------------------------------+---------------------------------------+
| "in", "not in", "is", "is not", "<", "<=", ">", | 비교, 멤버십 검사와 아이덴티티 검사를 |
| ">=", "<>", "!=", "=="                          | 포함한다                              |
+-------------------------------------------------+---------------------------------------+
| "|"                                             | 비트 OR                               |
+-------------------------------------------------+---------------------------------------+
| "^"                                             | 비트 XOR                              |
+-------------------------------------------------+---------------------------------------+
| "&"                                             | 비트 AND                              |
+-------------------------------------------------+---------------------------------------+
| "<<", ">>"                                      | 시프트                                |
+-------------------------------------------------+---------------------------------------+
| "+", "-"                                        | 덧셈과 뺄셈                           |
+-------------------------------------------------+---------------------------------------+
| "*", "/", "//", "%"                             | Multiplication, division, remainder   |
|                                                 | [7]                                   |
+-------------------------------------------------+---------------------------------------+
| "+x", "-x", "~x"                                | 양, 음, 비트 NOT                      |
+-------------------------------------------------+---------------------------------------+
| "**"                                            | 거듭제곱 [8]                          |
+-------------------------------------------------+---------------------------------------+
| "x[index]", "x[index:index]",                   | 서브스크립션, 슬라이싱, 호출, 어트리  |
| "x(arguments...)", "x.attribute"                | 뷰트 참조                             |
+-------------------------------------------------+---------------------------------------+
| "(expressions...)", "[expressions...]", "{key:  | Binding or tuple display, list        |
| value...}", "`expressions...`"                  | display, dictionary display, string   |
|                                                 | conversion                            |
+-------------------------------------------------+---------------------------------------+

-[ 각주 ]-

[1] In Python 2.3 and later releases, a list comprehension "leaks"
    the control variables of each "for" it contains into the
    containing scope.  However, this behavior is deprecated, and
    relying on it will not work in Python 3.

[2] "abs(x%y) < abs(y)" 이 수학적으로는 참이지만, float의 경우에는
    소 수점 자름(roundoff) 때문에 수치적으로 참이 아닐 수 있다. 예를
    들어 , 파이썬 float가 IEEE 754 배정도 숫자인 플랫폼을 가정할 때,
    "-1e-100 % 1e100" 가 "1e100" 와 같은 부호를 가지기 위해, 계산된 결
    과는 "-1e-100 + 1e100" 인데, 수치적으로는 "1e100" 과 정확히 같은
    값이다. 함수 "math.fmod()" 는 부호가 첫 번째 인자의 부호에 맞춰진
    결과를 주기 때문에, 이 경우 "-1e-100" 을 돌려준다. 어떤 접근법이
    더 적절한지는 응용 프로그램에 달려있다.

[3] If x is very close to an exact integer multiple of y, it's
    possible for "floor(x/y)" to be one larger than "(x-x%y)/y" due to
    rounding.  In such cases, Python returns the latter result, in
    order to preserve that "divmod(x,y)[0] * y + x % y" be very close
    to "x".

[4] 유니코드 표준은 코드 포인트(*code points*) (예를 들어, U+0041)
    와 추상 문자(*abstract characters*) (예를 들어, "LATIN CAPITAL
    LETTER A") 를 구분한다. 유니코드에 있는 대부분의 추상 문자들이 오
    직 하나 의 코드 포인트만으로 표현되지만, 추가로 하나 이상의 코드
    포인트의 시퀀스로 표현될 수 있는 추상 문자들이 많이 있다. 예를 들
    어, 추상 문자 "LATIN CAPITAL LETTER C WITH CEDILLA" 는 코드 위치
    U+00C7 에 있는 한 개의 복합 문자(*precomposed character*) 나 코드
    위치 U+0043 (LATIN CAPITAL LETTER C) 에 있는 기본 문자(*base
    character*) 와 뒤따르는 코드 위치 U+0327 (COMBINING CEDILLA) 에 있
    는 결합 문자(*combining character*) 의 시퀀스로 표현될 수 있다.

    The comparison operators on unicode strings compare at the level
    of Unicode code points. This may be counter-intuitive to humans.
    For example, "u"\u00C7" == u"\u0043\u0327"" is "False", even
    though both strings represent the same abstract character "LATIN
    CAPITAL LETTER C WITH CEDILLA".

    문자열을 추상 문자 수준에서 비교하려면 (즉, 사람에게 직관적인 방법
    으로), "unicodedata.normalize()" 를 사용하라.

[5] Earlier versions of Python used lexicographic comparison of
    the sorted (key, value) lists, but this was very expensive for the
    common case of comparing for equality.  An even earlier version of
    Python compared dictionaries by identity only, but this caused
    surprises because people expected to be able to test a dictionary
    for emptiness by comparing it to "{}".

[6] 자동 가비지-수거(automatic garbage-collection)와 자유 목록
    (free lists)과 디스크립터(descriptor)의 동적인 성격 때문에, "is"
    연산자 를 인스턴스 메서드들이나 상수들을 비교하는 것과 같은 특정한
    방식으 로 사용할 때, 겉으로 보기에 이상한 동작을 감지할 수 있다.
    더 자세 한 정보는 그들의 문서를 확인하기 바란다.

[7] "%" 연산자는 문자열 포매팅에도 사용된다; 같은 우선순위가 적용
    된다.

[8] 거듭제곱 연산자 "**" 는 오른쪽에 오는 산술이나 비트 일 항 연산
    자보 다 약하게 결합한다, 즉, "2**-1" 는 "0.5" 다.
