[Corso Python3] le cose davvero nuove ed importanti:
alessandro medici
alexxandro.medici a gmail.com
Mer 15 Giu 2016 23:37:32 CEST
context managerAn object which controls the environment seen in a with
<https://docs.python.org/3.6/reference/compound_stmts.html#with> statement
by defining __enter__()
<https://docs.python.org/3.6/reference/datamodel.html#object.__enter__> and
__exit__()
<https://docs.python.org/3.6/reference/datamodel.html#object.__exit__> methods.
See *PEP 343* <https://www.python.org/dev/peps/pep-0343>.coroutineCoroutines
is a more generalized form of subroutines. Subroutines are entered at one
point and exited at another point. Coroutines can be entered, exited, and
resumed at many different points. They can be implemented with the async def
<https://docs.python.org/3.6/reference/compound_stmts.html#async-def>
statement.
See also *PEP 492* <https://www.python.org/dev/peps/pep-0492>.coroutine
functionA function which returns a coroutine
<https://docs.python.org/3.6/glossary.html#term-coroutine> object. A
coroutine function may be defined with the async def
<https://docs.python.org/3.6/reference/compound_stmts.html#async-def>
statement,
and may contain await
<https://docs.python.org/3.6/reference/expressions.html#await>, async for
<https://docs.python.org/3.6/reference/compound_stmts.html#async-for>, and
async with
<https://docs.python.org/3.6/reference/compound_stmts.html#async-with>
keywords.
These were introduced by *PEP 492*
<https://www.python.org/dev/peps/pep-0492>.decorator
A function returning another function, usually applied as a function
transformation using the @wrapper syntax. Common examples for decorators
are classmethod()
<https://docs.python.org/3.6/library/functions.html#classmethod> and
staticmethod()
<https://docs.python.org/3.6/library/functions.html#staticmethod>.
The decorator syntax is merely syntactic sugar, the following two function
definitions are semantically equivalent:
def f(...):
...f = staticmethod(f)
@staticmethoddef f(...):
...
The same concept exists for classes, but is less commonly used there. See
the documentation for function definitions
<https://docs.python.org/3.6/reference/compound_stmts.html#function> and class
definitions
<https://docs.python.org/3.6/reference/compound_stmts.html#class> for more
about decorators.
descriptor
Any object which defines the methods __get__()
<https://docs.python.org/3.6/reference/datamodel.html#object.__get__>,
__set__()
<https://docs.python.org/3.6/reference/datamodel.html#object.__set__>, or
__delete__()
<https://docs.python.org/3.6/reference/datamodel.html#object.__delete__>.
When a class attribute is a descriptor, its special binding behavior is
triggered upon attribute lookup. Normally, using *a.b* to get, set or
delete an attribute looks up the object named *b* in the class dictionary
for *a*, but if *b* is a descriptor, the respective descriptor method gets
called. Understanding descriptors is a key to a deep understanding of
Python because they are the basis for many features including functions,
methods, properties, class methods, static methods, and reference to super
classes.
For more information about descriptors’ methods, see Implementing
Descriptors
<https://docs.python.org/3.6/reference/datamodel.html#descriptors>.
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.fsugpadova.org/pipermail/fsug-corso-python3/attachments/20160615/71b1ffd5/attachment.html>
Maggiori informazioni sulla lista
fsug-corso-python3