|
Original |
Translation |
|
25
|
Many standard library modules contain code that is invoked on their execution as a script. An example is the :mod:`timeit` module::
|
De nombreux modules de la bibliothèque standard contiennent du code qui est invoqué quand ils sont exécutés comme scripts. Un exemple est le module :mod:`timeit`\ ::
|
|
26
|
python -mtimeit -s 'setup here' 'benchmarked code here' python -mtimeit -h # for details
|
python -mtimeit -s 'préparation ici' 'code à chronométrer ici'python -mtimeit -h # pour les détails
|
|
27
|
|
|
|
28
|
:pep:`338` -- Executing modules as scripts
|
:pep:`338` -- Exécuter des modules en tant que scripts
|
|
29
|
Read commands from standard input (:data:`sys.stdin`). If standard input is a terminal, :option:`-i` is implied.
|
Lit les commandes depuis l'entrée standard (:data:`sys.stdin`). Si l'entrée standard est un terminal, l':option:`-i` est activée implicitement.
|
|
30
|
|
31
|
Execute the Python code contained in *script*, which must be a filesystem path (absolute or relative) referring to either a Python file, a directory containing a ``__main__.py`` file, or a zipfile containing a ``__main__.py`` file.
|
Exécute le code Python contenu dans *script*, qui doit être un chemin d'accès au fichier (absolu ou relatif), se référant à un fichier Python, à un répertoire contenant un fichier ``__main__.py`` ou à un fichier zip contenant un fichier ``__main__.py``.
|
|
32
|
If this option is given, the first element of :data:`sys.argv` will be the script name as given on the command line.
|
Si cette option est donnée, le premier élément de :data:`sys.argv` sera le nom du script comme donné sur la ligne de commande.
|
|
33
|
If the script name refers directly to a Python file, the directory containing that file is added to the start of :data:`sys.path`, and the file is executed as the :mod:`__main__` module.
|
Si le nom du script se réfère directement à un fichier Python, le répertoire contenant ce fichier est ajouté au début de :data:`sys.path`, et le fichier est exécuté en tant que module :mod:`__main__`.
|
|
34
|
If the script name refers to a directory or zipfile, the script name is added to the start of :data:`sys.path` and the ``__main__.py`` file in that location is executed as the :mod:`__main__` module.
|
Si le nom du script fait référence à un répertoire ou un fichier zip, le nom du script est ajouté au début de :data:`sys.path` et le fichier ``__main__.py`` à cet endroit est exécuté en tant que module :mod:`__main__`.
|