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. Appendix — Python 3.5.10 documentation
This document is for an old version of Python that is no longer supported.
You should upgrade, and read the
Python documentation for the current stable release.
16. Appendix¶16.1. Interactive Mode¶16.1.1. Error Handling¶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 Typing the interrupt character (usually Control-C or Delete) to the primary or
secondary prompt cancels the input and returns to the primary prompt. [1]
Typing an interrupt while a command is executing raises the
16.1.2. Executable Python Scripts¶On BSD’ish Unix systems, Python scripts can be made directly executable, like shell scripts, by putting the line #!/usr/bin/env python3.5
(assuming that the interpreter is on the user’s The script can be given an executable mode, or permission, using the chmod command. $ chmod +x myscript.py On Windows systems, there is no notion of an “executable mode”. The Python
installer automatically associates 16.1.3. The Interactive Startup File¶When you use Python interactively, it is frequently handy to have some standard
commands executed every time the interpreter is started. You can do this by
setting an environment variable named This file is only read in interactive sessions, not when Python reads commands
from a script, and not when If you want to read an additional start-up file from the current directory, you
can program this in the global start-up file using code like 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. The Customization Modules¶Python provides two hooks to let you customize it: >>> import site >>> site.getusersitepackages() '/home/user/.local/lib/python3.5/site-packages' Now you can create a file named
Footnotes
© Copyright 2001-2025, Python Software Foundation.
The Python Software Foundation is a non-profit corporation. Please donate. Last updated on Apr 16, 2025. Found a bug? Created using Sphinx 1.8.4. | ||
| 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. |