Original Translation
19
def f(...): ... f = staticmethod(f) @staticmethod def f(...): ...
def f(...): ... f = staticmethod(f) @staticmethod def f(...): ...
20
The same concept exists for classes, but is less commonly used there. See the documentation for :ref:`function definitions <function>` and :ref:`class definitions <class>` for more about decorators.
Quoique moins fréquemment utilisé, le même concept existe pour les classes. Consultez la documentation :ref:`définitions de fonctions <function> et :ref:`définitions de classes <class>` pour en savoir plus sur les decorators.
21
Any object which defines the methods :meth:`__get__`, :meth:`__set__`, or :meth:`__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.
N'importe quel objet définissant les méthodes :meth:`__get__`, :meth:`__set__`, ou :meth:`__delete__`. Lorsque l'attribut d'une classe est un descripteur, son comportement spécial est déclenché lors de la recherche des attributs. En utilisant *a.b* pour obtenir, valoriser ou effacer un attribut, il recherche l'objet nommé *b* dans la dictionnaire de la classe pour *a*, mais si *b* est un descripteur, la méthode de ce descripteur est alors appelée.Comprendre les descripteurs est la clé d'une compréhension approfondie de Python, ils sont la base de nombre de ses caractéristiques notamment les fonctions, méthodes, propriétés, méthodes de classe, méthodes statiques, et les références aux classes mères.
22
For more information about descriptors' methods, see :ref:`descriptors`.
Pour plus d'informations sur les méthodes des descripteurs, consultez :ref:`descriptors`.
23
An associative array, where arbitrary keys are mapped to values. The use of :class:`dict` closely resembles that for :class:`list`, but the keys can be any object with a :meth:`__hash__` function, not just integers. Called a hash in Perl.
24
A string literal which appears as the first expression in a class, function or module. While ignored when the suite is executed, it is recognized by the compiler and put into the :attr:`__doc__` attribute of the enclosing class, function or module. Since it is available via introspection, it is the canonical place for documentation of the object.
25
A pythonic programming style which determines an object's type by inspection of its method or attribute signature rather than by explicit relationship to some type object ("If it looks like a duck and quacks like a duck, it must be a duck.") By emphasizing interfaces rather than specific types, well-designed code improves its flexibility by allowing polymorphic substitution. Duck-typing avoids tests using :func:`type` or :func:`isinstance`. (Note, however, that duck-typing can be complemented with abstract base classes.) Instead, it typically employs :func:`hasattr` tests or :term:`EAFP` programming.
26
Easier to ask for forgiveness than permission. This common Python coding style assumes the existence of valid keys or attributes and catches exceptions if the assumption proves false. This clean and fast style is characterized by the presence of many :keyword:`try` and :keyword:`except` statements. The technique contrasts with the :term:`LBYL` style common to many other languages such as C.
27
A piece of syntax which can be evaluated to some value. In other words, an expression is an accumulation of expression elements like literals, names, attribute access, operators or function calls which all return a value. In contrast to many other languages, not all language constructs are expressions. There are also :term:`statement`\s which cannot be used as expressions, such as :keyword:`if`. Assignments are also statements, not expressions.
Une suite logique de termes et chiffres conformes à la syntaxe Python dont l'évaluation fournit une valeur. En d'autres termes, une expression est une suite d'éléments tels que des noms, opérateurs, littéraux, accès d'attributs, méthodes ou fonctions qui aboutissent à une valeur. Contrairement à beaucoup d'autres langages, les différentes constructions du langage ne sont pas toutes des expressions. Il y a également des :term:`statement`s qui ne peuvent pas être utilisés comme expressions, tel que :keyword:`if`. Les affectations sont également des :term:`statements` et non des expressions.
28
A module written in C or C++, using Python's C API to interact with the core and with user code.
Un module écrit en C ou C++, utilisant l'API C de Python afin d'intéragir avec le noyau et le code utilisateur.