| object. Note that this may execute application-defined code if an object with a |
| :meth:`__getattr__` method is part of the expression. |
| |
| A more capable startup file might look like this example. Note that this |
| deletes the names it creates once they are no longer needed; this is done since |
| the startup file is executed in the same namespace as the interactive commands, |
| and removing the names avoids creating side effects in the interactive |
| environment. You may find it convenient to keep some of the imported modules, |
n | such as :mod:`os` (XXX reference: ../lib/module-os.html), which turn out to be |
n | such as :mod:`os`, which turn out to be needed in most sessions with the |
| needed in most sessions with the interpreter. :: |
| interpreter. :: |
| |
| # Add auto-completion and a stored history file of commands to your Python |
| # interactive interpreter. Requires Python 2.0+, readline. Autocomplete is |
| # bound to the Esc key by default (you can change it - see readline docs). |
| # |
| # Store the file in ~/.pystartup, and set an environment variable to point |
t | # to it: "export PYTHONSTARTUP=/max/home/itamar/.pystartup" in bash. |
t | # to it: "export PYTHONSTARTUP=/home/user/.pystartup" in bash. |
| # |
| # Note that PYTHONSTARTUP does *not* expand "~", so you have to put in the |
| # full path to your home directory. |
| |
| import atexit |
| import os |
| import readline |
| import rlcompleter |