GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing docs.python.org — 16. Annexe 16. Annexe¶16.1. Mode interactif¶There are two variants of the interactive REPL. The classic basic interpreter is supported on all platforms with minimal line control capabilities. Since Python 3.13, a new interactive shell is used by default.
This one supports color, multiline editing, history browsing, and
paste mode. To disable color, see Controlling color for
details. Function keys provide some additional functionality.
F1 enters the interactive help browser When using the new interactive shell, exit the shell by typing exit or quit. Adding call parentheses after those commands is not required. If the new interactive shell is not desired, it can be disabled via
the 16.1.1. Gestion des erreurs¶When an error occurs, the interpreter prints an error message and a stack trace.
In interactive mode, it then returns to the primary prompt; when input came from
a file, it exits with a nonzero exit status after printing the stack trace.
(Exceptions handled by an Taper le caractère d'interruption (généralement Ctrl+C ou Supprimer) au niveau de l'invite de commande primaire annule l'entrée et revient à l'invite [1]. Saisir une interruption tandis qu'une commande s'exécute lève une exception 16.1.2. Scripts Python exécutables¶Sur les systèmes Unix, un script Python peut être rendu directement exécutable, comme un script shell, en ajoutant la ligne #!/usr/bin/env python3
(en supposant que l'interpréteur est dans le Un script peut être rendu exécutable en utilisant la commande chmod. $ chmod +x myscript.py Sur les systèmes Windows il n'y a pas de "mode exécutable". L'installateur Python associe automatiquement les fichiers en 16.1.3. Configuration du mode interactif¶En mode interactif, il peut être pratique de faire exécuter quelques commandes au lancement de l’interpréteur. Configurez la variable d'environnement Ce fichier n'est lu qu'en mode interactif, pas quand Python lit les instructions depuis un fichier, ni quand Si vous voulez exécuter d'autres fichiers du dossier courant au démarrage, vous pouvez le programmer dans le fichier de démarrage global, par exemple avec le code suivant : import os filename = os.environ.get('PYTHONSTARTUP') if filename and os.path.isfile(filename): with open(filename) as fobj: startup_file = fobj.read() exec(startup_file) 16.1.4. Modules de personnalisation¶Python provides two hooks to let you customize it: sitecustomize and usercustomize. To see how it works, you need first to find the location of your user site-packages directory. Start Python and run this code: >>> import site >>> site.getusersitepackages() '/home/user/.local/lib/python3.x/site-packages' Vous pouvez maintenant y créer un fichier sitecustomize works in the same way, but is typically created by an
administrator of the computer in the global site-packages directory, and is
imported before usercustomize. See the documentation of the Notes
© Copyright 2001 Python Software Foundation.
La licence de cette page est la Python Software Foundation License Version 2. La licence des exemples, recettes, et autres morceaux de code se trouvant dans la documentation est la Zero Clause BSD License. Pour plus d'informations, consultez Histoire et licence. La Python Software Foundation est une association à but non lucratif. Elle vit de vos dons. Dernière mise à jour : nov. 12, 2026 (05:04 UTC). Un bogue ? Crée par Sphinx 9.1.1. |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |