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-sidebar.org — 16. Appendix 16. Appendix16.1. Interactive Mode16.1.1. Error HandlingWhen 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 ScriptsOn 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 FileWhen 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 ModulesPython 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
|
| 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. |