Developpez.com

Python

Choisissez la catégorie, puis la rubrique :

23.2.6.2 Example Objects


23.2.6.2 Example Objects

class Example( source, want[, exc_msg][, lineno][, indent][, options])
A single interactive example, consisting of a Python statement and its expected output. The constructor arguments are used to initialize the member variables of the same names. New in version 2.4.

Example defines the following member variables. They are initialized by the constructor, and should not be modified directly.

source
A string containing the example's source code. This source code consists of a single Python statement, and always ends with a newline; the constructor adds a newline when necessary.

want
The expected output from running the example's source code (either from stdout, or a traceback in case of exception). want ends with a newline unless no output is expected, in which case it's an empty string. The constructor adds a newline when necessary.

exc_msg
The exception message generated by the example, if the example is expected to generate an exception; or None if it is not expected to generate an exception. This exception message is compared against the return value of traceback.format_exception_only(). exc_msg ends with a newline unless it's None. The constructor adds a newline if needed.

lineno
The line number within the string containing this example where the example begins. This line number is zero-based with respect to the beginning of the containing string.

indent
The example's indentation in the containing string, i.e., the number of space characters that precede the example's first prompt.

options
A dictionary mapping from option flags to True or False, which is used to override default options for this example. Any option flags not contained in this dictionary are left at their default value (as specified by the DocTestRunner's optionflags). By default, no options are set.

See About this document... for information on suggesting changes.
Netflix : Python est derrière chaque film que vous regardez, voici comment l'entreprise utilise le langage de programmation pour ses services
Une plateforme de recrutement s'intéresse aux tendances des ingénieurs en matière d'outils de développement, et note la montée en puissance de VS Code
Les tendances des développeurs pour 2019 font du Machine Learning la compétence clé et du JavaScript le langage le plus populaire
Apprendre à coder correctement - Un guide concis pour écrire un meilleur code, par Robat Williams, traduit par vavavoum74
Contacter le responsable de la rubrique Python

Partenaire : Hébergement Web