Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9a4e3fc

Browse files
committed
Changed references to /usr/local into /usr/local/bin.
Documented $PYTHONSTARTUP
1 parent 2dff991 commit 9a4e3fc

2 files changed

Lines changed: 62 additions & 18 deletions

File tree

Doc/tut.tex

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ \chapter{Using the Python Interpreter}
147147

148148
\section{Invoking the Interpreter}
149149

150-
The Python interpreter is usually installed as {\tt /usr/local/python}
151-
on those machines where it is available; putting {\tt /usr/local} in
150+
The Python interpreter is usually installed as {\tt /usr/local/bin/python}
151+
on those machines where it is available; putting {\tt /usr/local/bin} in
152152
your {\UNIX} shell's search path makes it possible to start it by
153153
typing the command
154154

@@ -159,7 +159,7 @@ \section{Invoking the Interpreter}
159159
to the shell. Since the choice of the directory where the interpreter
160160
lives is an installation option, other places are possible; check with
161161
your local Python guru or system administrator. (E.g., {\tt
162-
/usr/local/bin/python} is a popular alternative location.)
162+
/usr/local/python} is a popular alternative location.)
163163

164164
The interpreter operates somewhat like the {\UNIX} shell: when called
165165
with standard input connected to a tty device, it reads and executes
@@ -211,7 +211,7 @@ \subsection{Interactive Mode}
211211

212212
\bcode\begin{verbatim}
213213
python
214-
Python 0.9.5 (Jan 2 1992).
214+
Python 0.9.7 (Aug 28 1992).
215215
Copyright 1990, 1991, 1992 Stichting Mathematisch Centrum, Amsterdam
216216
>>>
217217
\end{verbatim}\ecode
@@ -248,12 +248,12 @@ \subsection{The Module Search Path}
248248
for a file named {\tt foo.py} in the list of directories specified by
249249
the environment variable {\tt PYTHONPATH}. It has the same syntax as
250250
the {\UNIX} shell variable {\tt PATH}, i.e., a list of colon-separated
251-
directory names. When {\tt PYTHONPATH} is not set, an
252-
installation-dependent default path is used, usually {\tt
253-
.:/usr/local/lib/python}.
251+
directory names. When {\tt PYTHONPATH} is not set, or when the file
252+
is not found there, the search continues in an installation-dependent
253+
default path, usually {\tt .:/usr/local/lib/python}.
254254

255255
Actually, modules are searched in the list of directories given by the
256-
variable {\tt sys.path} which is initialized from {\tt PYTHONPATH} or
256+
variable {\tt sys.path} which is initialized from {\tt PYTHONPATH} and
257257
the installation-dependent default. This allows Python programs that
258258
know what they're doing to modify or replace the module search path.
259259
See the section on Standard Modules later.
@@ -280,13 +280,35 @@ \subsection{Executable Python scripts}
280280
executable, like shell scripts, by putting the line
281281

282282
\bcode\begin{verbatim}
283-
#! /usr/local/python
283+
#! /usr/local/bin/python
284284
\end{verbatim}\ecode
285285
%
286286
(assuming that's the name of the interpreter) at the beginning of the
287287
script and giving the file an executable mode. The {\tt \#!} must be
288288
the first two characters of the file.
289289

290+
\subsection{The Interactive Startup File}
291+
292+
When you use Python interactively, it is frequently handy to have some
293+
standard commands executed every time the interpreter is started. You
294+
can do this by setting an environment variable named {\tt
295+
PYTHONSTARTUP} to the name of a file containing your start-up
296+
commands. This is similar to the {\tt /profile} feature of the UNIX
297+
shells.
298+
299+
This file is only read in interactive sessions, not when Python reads
300+
commands from a script, and not when {\tt /dev/tty} is given as the
301+
explicit source of commands (which otherwise behaves like an
302+
interactive session). It is executed in the same name space where
303+
interactive commands are executed, so that objects that it defines or
304+
imports can be used without qualification in the interactive session.
305+
306+
If you want to read an additional start-up file from the current
307+
directory, you can program this in the global start-up file, e.g.
308+
\verb\execfile('.pythonrc')\. If you want to use the startup file
309+
in a script, you must write this explicitly in the script, e.g.
310+
\verb\import os;\ \verb\execfile(os.environ['PYTHONSTARTUP'])\.
311+
290312
\section{Interactive Input Editing and History Substitution}
291313

292314
Some versions of the Python interpreter support editing of the current

Doc/tut/tut.tex

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ \chapter{Using the Python Interpreter}
147147

148148
\section{Invoking the Interpreter}
149149

150-
The Python interpreter is usually installed as {\tt /usr/local/python}
151-
on those machines where it is available; putting {\tt /usr/local} in
150+
The Python interpreter is usually installed as {\tt /usr/local/bin/python}
151+
on those machines where it is available; putting {\tt /usr/local/bin} in
152152
your {\UNIX} shell's search path makes it possible to start it by
153153
typing the command
154154

@@ -159,7 +159,7 @@ \section{Invoking the Interpreter}
159159
to the shell. Since the choice of the directory where the interpreter
160160
lives is an installation option, other places are possible; check with
161161
your local Python guru or system administrator. (E.g., {\tt
162-
/usr/local/bin/python} is a popular alternative location.)
162+
/usr/local/python} is a popular alternative location.)
163163

164164
The interpreter operates somewhat like the {\UNIX} shell: when called
165165
with standard input connected to a tty device, it reads and executes
@@ -211,7 +211,7 @@ \subsection{Interactive Mode}
211211

212212
\bcode\begin{verbatim}
213213
python
214-
Python 0.9.5 (Jan 2 1992).
214+
Python 0.9.7 (Aug 28 1992).
215215
Copyright 1990, 1991, 1992 Stichting Mathematisch Centrum, Amsterdam
216216
>>>
217217
\end{verbatim}\ecode
@@ -248,12 +248,12 @@ \subsection{The Module Search Path}
248248
for a file named {\tt foo.py} in the list of directories specified by
249249
the environment variable {\tt PYTHONPATH}. It has the same syntax as
250250
the {\UNIX} shell variable {\tt PATH}, i.e., a list of colon-separated
251-
directory names. When {\tt PYTHONPATH} is not set, an
252-
installation-dependent default path is used, usually {\tt
253-
.:/usr/local/lib/python}.
251+
directory names. When {\tt PYTHONPATH} is not set, or when the file
252+
is not found there, the search continues in an installation-dependent
253+
default path, usually {\tt .:/usr/local/lib/python}.
254254

255255
Actually, modules are searched in the list of directories given by the
256-
variable {\tt sys.path} which is initialized from {\tt PYTHONPATH} or
256+
variable {\tt sys.path} which is initialized from {\tt PYTHONPATH} and
257257
the installation-dependent default. This allows Python programs that
258258
know what they're doing to modify or replace the module search path.
259259
See the section on Standard Modules later.
@@ -280,13 +280,35 @@ \subsection{Executable Python scripts}
280280
executable, like shell scripts, by putting the line
281281

282282
\bcode\begin{verbatim}
283-
#! /usr/local/python
283+
#! /usr/local/bin/python
284284
\end{verbatim}\ecode
285285
%
286286
(assuming that's the name of the interpreter) at the beginning of the
287287
script and giving the file an executable mode. The {\tt \#!} must be
288288
the first two characters of the file.
289289

290+
\subsection{The Interactive Startup File}
291+
292+
When you use Python interactively, it is frequently handy to have some
293+
standard commands executed every time the interpreter is started. You
294+
can do this by setting an environment variable named {\tt
295+
PYTHONSTARTUP} to the name of a file containing your start-up
296+
commands. This is similar to the {\tt /profile} feature of the UNIX
297+
shells.
298+
299+
This file is only read in interactive sessions, not when Python reads
300+
commands from a script, and not when {\tt /dev/tty} is given as the
301+
explicit source of commands (which otherwise behaves like an
302+
interactive session). It is executed in the same name space where
303+
interactive commands are executed, so that objects that it defines or
304+
imports can be used without qualification in the interactive session.
305+
306+
If you want to read an additional start-up file from the current
307+
directory, you can program this in the global start-up file, e.g.
308+
\verb\execfile('.pythonrc')\. If you want to use the startup file
309+
in a script, you must write this explicitly in the script, e.g.
310+
\verb\import os;\ \verb\execfile(os.environ['PYTHONSTARTUP'])\.
311+
290312
\section{Interactive Input Editing and History Substitution}
291313

292314
Some versions of the Python interpreter support editing of the current

0 commit comments

Comments
 (0)