Commit 687ed860 authored by Guido van Rossum's avatar Guido van Rossum

Changed references to /usr/local into /usr/local/bin.

Documented $PYTHONSTARTUP
parent 744d3ad8
...@@ -147,8 +147,8 @@ modules that can save you a lot of time when writing Python programs. ...@@ -147,8 +147,8 @@ modules that can save you a lot of time when writing Python programs.
\section{Invoking the Interpreter} \section{Invoking the Interpreter}
The Python interpreter is usually installed as {\tt /usr/local/python} The Python interpreter is usually installed as {\tt /usr/local/bin/python}
on those machines where it is available; putting {\tt /usr/local} in on those machines where it is available; putting {\tt /usr/local/bin} in
your {\UNIX} shell's search path makes it possible to start it by your {\UNIX} shell's search path makes it possible to start it by
typing the command typing the command
...@@ -159,7 +159,7 @@ python ...@@ -159,7 +159,7 @@ python
to the shell. Since the choice of the directory where the interpreter to the shell. Since the choice of the directory where the interpreter
lives is an installation option, other places are possible; check with lives is an installation option, other places are possible; check with
your local Python guru or system administrator. (E.g., {\tt your local Python guru or system administrator. (E.g., {\tt
/usr/local/bin/python} is a popular alternative location.) /usr/local/python} is a popular alternative location.)
The interpreter operates somewhat like the {\UNIX} shell: when called The interpreter operates somewhat like the {\UNIX} shell: when called
with standard input connected to a tty device, it reads and executes with standard input connected to a tty device, it reads and executes
...@@ -211,7 +211,7 @@ and a copyright notice before printing the first prompt, e.g.: ...@@ -211,7 +211,7 @@ and a copyright notice before printing the first prompt, e.g.:
\bcode\begin{verbatim} \bcode\begin{verbatim}
python python
Python 0.9.5 (Jan 2 1992). Python 0.9.7 (Aug 28 1992).
Copyright 1990, 1991, 1992 Stichting Mathematisch Centrum, Amsterdam Copyright 1990, 1991, 1992 Stichting Mathematisch Centrum, Amsterdam
>>> >>>
\end{verbatim}\ecode \end{verbatim}\ecode
...@@ -248,12 +248,12 @@ When a module named {\tt foo} is imported, the interpreter searches ...@@ -248,12 +248,12 @@ When a module named {\tt foo} is imported, the interpreter searches
for a file named {\tt foo.py} in the list of directories specified by for a file named {\tt foo.py} in the list of directories specified by
the environment variable {\tt PYTHONPATH}. It has the same syntax as the environment variable {\tt PYTHONPATH}. It has the same syntax as
the {\UNIX} shell variable {\tt PATH}, i.e., a list of colon-separated the {\UNIX} shell variable {\tt PATH}, i.e., a list of colon-separated
directory names. When {\tt PYTHONPATH} is not set, an directory names. When {\tt PYTHONPATH} is not set, or when the file
installation-dependent default path is used, usually {\tt is not found there, the search continues in an installation-dependent
.:/usr/local/lib/python}. default path, usually {\tt .:/usr/local/lib/python}.
Actually, modules are searched in the list of directories given by the Actually, modules are searched in the list of directories given by the
variable {\tt sys.path} which is initialized from {\tt PYTHONPATH} or variable {\tt sys.path} which is initialized from {\tt PYTHONPATH} and
the installation-dependent default. This allows Python programs that the installation-dependent default. This allows Python programs that
know what they're doing to modify or replace the module search path. know what they're doing to modify or replace the module search path.
See the section on Standard Modules later. See the section on Standard Modules later.
...@@ -280,13 +280,35 @@ On BSD'ish {\UNIX} systems, Python scripts can be made directly ...@@ -280,13 +280,35 @@ On BSD'ish {\UNIX} systems, Python scripts can be made directly
executable, like shell scripts, by putting the line executable, like shell scripts, by putting the line
\bcode\begin{verbatim} \bcode\begin{verbatim}
#! /usr/local/python #! /usr/local/bin/python
\end{verbatim}\ecode \end{verbatim}\ecode
% %
(assuming that's the name of the interpreter) at the beginning of the (assuming that's the name of the interpreter) at the beginning of the
script and giving the file an executable mode. The {\tt \#!} must be script and giving the file an executable mode. The {\tt \#!} must be
the first two characters of the file. the first two characters of the file.
\subsection{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 {\tt
PYTHONSTARTUP} to the name of a file containing your start-up
commands. This is similar to the {\tt /profile} feature of the UNIX
shells.
This file is only read in interactive sessions, not when Python reads
commands from a script, and not when {\tt /dev/tty} is given as the
explicit source of commands (which otherwise behaves like an
interactive session). It is executed in the same name space where
interactive commands are executed, so that objects that it defines or
imports can be used without qualification in the interactive session.
If you want to read an additional start-up file from the current
directory, you can program this in the global start-up file, e.g.
\verb\execfile('.pythonrc')\. If you want to use the startup file
in a script, you must write this explicitly in the script, e.g.
\verb\import os;\ \verb\execfile(os.environ['PYTHONSTARTUP'])\.
\section{Interactive Input Editing and History Substitution} \section{Interactive Input Editing and History Substitution}
Some versions of the Python interpreter support editing of the current Some versions of the Python interpreter support editing of the current
......
...@@ -147,8 +147,8 @@ modules that can save you a lot of time when writing Python programs. ...@@ -147,8 +147,8 @@ modules that can save you a lot of time when writing Python programs.
\section{Invoking the Interpreter} \section{Invoking the Interpreter}
The Python interpreter is usually installed as {\tt /usr/local/python} The Python interpreter is usually installed as {\tt /usr/local/bin/python}
on those machines where it is available; putting {\tt /usr/local} in on those machines where it is available; putting {\tt /usr/local/bin} in
your {\UNIX} shell's search path makes it possible to start it by your {\UNIX} shell's search path makes it possible to start it by
typing the command typing the command
...@@ -159,7 +159,7 @@ python ...@@ -159,7 +159,7 @@ python
to the shell. Since the choice of the directory where the interpreter to the shell. Since the choice of the directory where the interpreter
lives is an installation option, other places are possible; check with lives is an installation option, other places are possible; check with
your local Python guru or system administrator. (E.g., {\tt your local Python guru or system administrator. (E.g., {\tt
/usr/local/bin/python} is a popular alternative location.) /usr/local/python} is a popular alternative location.)
The interpreter operates somewhat like the {\UNIX} shell: when called The interpreter operates somewhat like the {\UNIX} shell: when called
with standard input connected to a tty device, it reads and executes with standard input connected to a tty device, it reads and executes
...@@ -211,7 +211,7 @@ and a copyright notice before printing the first prompt, e.g.: ...@@ -211,7 +211,7 @@ and a copyright notice before printing the first prompt, e.g.:
\bcode\begin{verbatim} \bcode\begin{verbatim}
python python
Python 0.9.5 (Jan 2 1992). Python 0.9.7 (Aug 28 1992).
Copyright 1990, 1991, 1992 Stichting Mathematisch Centrum, Amsterdam Copyright 1990, 1991, 1992 Stichting Mathematisch Centrum, Amsterdam
>>> >>>
\end{verbatim}\ecode \end{verbatim}\ecode
...@@ -248,12 +248,12 @@ When a module named {\tt foo} is imported, the interpreter searches ...@@ -248,12 +248,12 @@ When a module named {\tt foo} is imported, the interpreter searches
for a file named {\tt foo.py} in the list of directories specified by for a file named {\tt foo.py} in the list of directories specified by
the environment variable {\tt PYTHONPATH}. It has the same syntax as the environment variable {\tt PYTHONPATH}. It has the same syntax as
the {\UNIX} shell variable {\tt PATH}, i.e., a list of colon-separated the {\UNIX} shell variable {\tt PATH}, i.e., a list of colon-separated
directory names. When {\tt PYTHONPATH} is not set, an directory names. When {\tt PYTHONPATH} is not set, or when the file
installation-dependent default path is used, usually {\tt is not found there, the search continues in an installation-dependent
.:/usr/local/lib/python}. default path, usually {\tt .:/usr/local/lib/python}.
Actually, modules are searched in the list of directories given by the Actually, modules are searched in the list of directories given by the
variable {\tt sys.path} which is initialized from {\tt PYTHONPATH} or variable {\tt sys.path} which is initialized from {\tt PYTHONPATH} and
the installation-dependent default. This allows Python programs that the installation-dependent default. This allows Python programs that
know what they're doing to modify or replace the module search path. know what they're doing to modify or replace the module search path.
See the section on Standard Modules later. See the section on Standard Modules later.
...@@ -280,13 +280,35 @@ On BSD'ish {\UNIX} systems, Python scripts can be made directly ...@@ -280,13 +280,35 @@ On BSD'ish {\UNIX} systems, Python scripts can be made directly
executable, like shell scripts, by putting the line executable, like shell scripts, by putting the line
\bcode\begin{verbatim} \bcode\begin{verbatim}
#! /usr/local/python #! /usr/local/bin/python
\end{verbatim}\ecode \end{verbatim}\ecode
% %
(assuming that's the name of the interpreter) at the beginning of the (assuming that's the name of the interpreter) at the beginning of the
script and giving the file an executable mode. The {\tt \#!} must be script and giving the file an executable mode. The {\tt \#!} must be
the first two characters of the file. the first two characters of the file.
\subsection{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 {\tt
PYTHONSTARTUP} to the name of a file containing your start-up
commands. This is similar to the {\tt /profile} feature of the UNIX
shells.
This file is only read in interactive sessions, not when Python reads
commands from a script, and not when {\tt /dev/tty} is given as the
explicit source of commands (which otherwise behaves like an
interactive session). It is executed in the same name space where
interactive commands are executed, so that objects that it defines or
imports can be used without qualification in the interactive session.
If you want to read an additional start-up file from the current
directory, you can program this in the global start-up file, e.g.
\verb\execfile('.pythonrc')\. If you want to use the startup file
in a script, you must write this explicitly in the script, e.g.
\verb\import os;\ \verb\execfile(os.environ['PYTHONSTARTUP'])\.
\section{Interactive Input Editing and History Substitution} \section{Interactive Input Editing and History Substitution}
Some versions of the Python interpreter support editing of the current Some versions of the Python interpreter support editing of the current
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment