Title: Theory / Important / CS / Programming / Python / Manual{ / 6 Expressions
Tags: FromInstruction computer_to_instruction hasNotNewEffectReturnsMeaning some_instruction récupéré automatedNewLineAfterCommaSpace

Question: The result of an arithmetic operation is
Answer: Complex if one is complex.
Otherwise float if one is float
Otherwise int
Chapter: 6
Section: 1
Context: Python

Name: Atoms
Definition: identifier
Chapter: 6
Section: 2
Context: python
Definition2: literal
Conjdef: either
Definition3: enclosure
Intuition: the most basic elements of expressions

Name: enclosure
Definition: parenth_form
Chapter: 6
Section: 2
Definition2: list_display
Definition3: dict_display
Definition4: set_display
Definition5: generator_expression
Definition6: yield_atom

Name: parenth_forrm
Definition: “(” [starred_expression] “)”
Chapter: 6
Section: 2.3

Name: A display
Definition: explicitly listing content
Chapter: 6
Section: 2.4
Context: Python
Example: comprehension
Conjdef: either
DefType: The form used to create a list, set or dictionnary explicitly

Name: A comprehension
Definition: A single expression followed by at least one
for clause and zero or more for or if clauses.
Chapter: 6
Section: 2.4
Context: Pyrhon
Example: for elt in elts if p(elt)

Instruction: yeld from expr
Effect: As a yeld on each elements returned by expr. Values passed with send() and exceptions passed with throw() are passed to the underlying iterator if it has the
appropriate methods.
Language: Python
Chapter: 6
Section: 2.9
Assuming: expr is a generator
Exception: If the underlying iterator can't handle it send() will raise AttributeError or TypeError, while throw() will just raise the passed in exception immediately.

Name: A generator
Definition: An object returning successivly elements. Potentially taking parameters between successive elements
Chapter: 6
Section: 2.9
Extra: doublon

Instruction: g.close()
Effect: Raises a GeneratorExit at the point where the generator function was paused. If the generator function then exits gracefully, is already closed, or raises GeneratorExit (by not catching the exception), it 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. This method does nothing if the generator has already exited due to an exception or normal exit.
Language: Python
Chapter: 6
Section: 2.9.1
Variables: g a generator

Instruction: StopIteration
Effect: The exception raised by a generator exiting without yelding a value
Language: Python
Chapter: 6
Section: 2.9.1

Instruction: GeneratorExit
Effect: The exception stating a generator that it should close
Language: Python
Chapter: 6
Section: 2.9.1

Instruction: async generator
Effect: todo later
Language: Python
Chapter: 6
Section: 2.9.1

Instruction: primary.identifier
Language: Python
Chapter: 6
Section: 3.1
Returns: The value designed by identifier from primary. Formally, the result comes from __getattr__(primary,identifier).
Name: Attribute reference
Exception: raises AttributeError if the identifier does not exists

Instruction: primary[expression_list]
Language: Python
Chapter: 6
Section: 3.2
Returns: The value designed by expression_list from primary. Formally, the result comes from __getitem__(primary,expression_list).
Name: Subscriptions
Exception: raises AttributeError if the identifier does not exists

Instruction: expression for x_1,...,x_n in test
Effect: The elements of the new container 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 an element each time the innermost block is reached.
Language: Python
Chapter: 6
Section: 2.4

Instruction: [starred_list|comprehension]
Effect: The list with elements mentionned in the arguments
Language: Python
Chapter: 6
Section: 2.5

Instruction: {starred_list|comprehension}
Effect: A mutable set whose content is mentionned in the arguments
Language: Python
Chapter: 6
Section: 2.6

Instruction: {... **dict ...}
Effect: Unpack the content of dict into the currently created dictionnary
Language: Python
Chapter: 6
Section: 2.6

Instruction: ... *set ...
Effect: Unpack the content of set into the currently created list/set
Language: Python
Chapter: 6, PEP 448
Section: 2.6

Instruction: yeld expr
Effect: Sends the value of expr to the generator's
Language: Python
Chapter: 6
Section: 2.9
Returns: either None, or the value sent by the calls send(a) on the generator

Instruction: g.__next__()
Effect: Starts the execution of a generator function or resumes it at the last executed yield expression. When a generator function is resumed with this method, the current yield expression always evaluates to None. The execution then continues to the next yield expression, where the generator is suspended again
Language: Python
Chapter: 6
Section: 2.9.1
Returns: The value returned by the next yield expression in g
Variables: g a generator
Intuition: This method is normally called implicitly, e.g. by a for loop, or by the built-in next() function.
Exception: If the generator exits without yielding another value, a StopIteration exception is raised.

Instruction: g.send()
Effect: Resumes the execution and “sends” a value into the generator function. The
value argument becomes the result of the current yield expression.
Language: Python
Chapter: 6
Section: 2.9.1
Returns: the next value yielded by the generator
Variables: g a generator
Assuming: 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.
Exception: raises StopIteration if the generator exits without yielding another value.

Instruction: g.throw(t)
g.throw(t, v),
g.throw(t, v, r)
Effect: Raises an exception of type type at the point where the generator was paused.
Language: Python
Chapter: 6
Section: 2.9.1
Returns: the next value yielded by the generator function
Variables: g a generator
Exception: 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.