]> granicus.if.org Git - python/commitdiff
Fixed example to load the startup file from a script (didn't test for the
authorFred Drake <fdrake@acm.org>
Mon, 13 Apr 1998 01:31:10 +0000 (01:31 +0000)
committerFred Drake <fdrake@acm.org>
Mon, 13 Apr 1998 01:31:10 +0000 (01:31 +0000)
file's existance).

Removed some XXX comments about extension modules which support pickling.

Added text from AMK about the readline and rlcompleter modules.

Thanks, AMK!

Doc/tut.tex
Doc/tut/tut.tex

index 03079707a36e4121ee7241e720e6c26211b57e5f..f8b198daab9094cfadf4ae96893465303cf28db1 100644 (file)
@@ -317,15 +317,18 @@ You can also change the prompts \code{sys.ps1} and \code{sys.ps2} in
 this file.
 
 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.
-\samp{execfile('.pythonrc')}.  If you want to use the startup file
-in a script, you must write this explicitly in the script:
+directory, you can program this in the global start-up file,
+e.g.\ \samp{execfile('.pythonrc')}\indexii{.pythonrc.py}{file}.  If
+you want to use the startup file in a script, you must do this
+explicitly in the script:
 
 \begin{verbatim}
 import os
-execfile(os.environ['PYTHONSTARTUP'])
+if os.path.isfile(os.environ['PYTHONSTARTUP']):
+    execfile(os.environ['PYTHONSTARTUP'])
 \end{verbatim}
 
+
 \chapter{An Informal Introduction to Python}
 \label{informal}
 
@@ -2313,8 +2316,7 @@ stored and reused by other programs or by a future invocation of the
 same program; the technical term for this is a \dfn{persistent}
 object.  Because \module{pickle} is so widely used, many authors who
 write Python extensions take care to ensure that new data types such
-as matrices, XXX more examples needed XXX, can be properly pickled and
-unpickled.
+as matrices can be properly pickled and unpickled.
 
 
 
@@ -3454,6 +3456,28 @@ TAB: complete
 in your \file{\$HOME/.inputrc}.  (Of course, this makes it hard to type
 indented continuation lines...)
 
+Automatic completion of variable and module names is optionally
+available.  To enable it in the interpreter's interactive mode, add
+the following to your \file{\$HOME/.pythonrc} file:% $ <- bow to font-lock
+\indexii{.pythonrc.py}{file}%
+\refstmodindex{rlcompleter}%
+\refbimodindex{readline}
+
+\begin{verbatim}
+import rlcompleter, readline
+readline.parse_and_bind('tab: complete')
+\end{verbatim}
+
+This binds the TAB key to the completion function, so hitting the TAB
+key twice suggests completions; it looks at Python statement names,
+the current local variables, and the available module names.  For
+dotted expressions such as \code{string.a}, it will evaluate the the
+expression up to the final \character{.} and then suggest completions
+from the attributes of the resulting object.  Note that this may
+execute application-defined code if an object with a
+\method{__getattr__()} method is part of the expression.
+
+
 \section{Commentary}
 \label{commentary}
 
index 03079707a36e4121ee7241e720e6c26211b57e5f..f8b198daab9094cfadf4ae96893465303cf28db1 100644 (file)
@@ -317,15 +317,18 @@ You can also change the prompts \code{sys.ps1} and \code{sys.ps2} in
 this file.
 
 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.
-\samp{execfile('.pythonrc')}.  If you want to use the startup file
-in a script, you must write this explicitly in the script:
+directory, you can program this in the global start-up file,
+e.g.\ \samp{execfile('.pythonrc')}\indexii{.pythonrc.py}{file}.  If
+you want to use the startup file in a script, you must do this
+explicitly in the script:
 
 \begin{verbatim}
 import os
-execfile(os.environ['PYTHONSTARTUP'])
+if os.path.isfile(os.environ['PYTHONSTARTUP']):
+    execfile(os.environ['PYTHONSTARTUP'])
 \end{verbatim}
 
+
 \chapter{An Informal Introduction to Python}
 \label{informal}
 
@@ -2313,8 +2316,7 @@ stored and reused by other programs or by a future invocation of the
 same program; the technical term for this is a \dfn{persistent}
 object.  Because \module{pickle} is so widely used, many authors who
 write Python extensions take care to ensure that new data types such
-as matrices, XXX more examples needed XXX, can be properly pickled and
-unpickled.
+as matrices can be properly pickled and unpickled.
 
 
 
@@ -3454,6 +3456,28 @@ TAB: complete
 in your \file{\$HOME/.inputrc}.  (Of course, this makes it hard to type
 indented continuation lines...)
 
+Automatic completion of variable and module names is optionally
+available.  To enable it in the interpreter's interactive mode, add
+the following to your \file{\$HOME/.pythonrc} file:% $ <- bow to font-lock
+\indexii{.pythonrc.py}{file}%
+\refstmodindex{rlcompleter}%
+\refbimodindex{readline}
+
+\begin{verbatim}
+import rlcompleter, readline
+readline.parse_and_bind('tab: complete')
+\end{verbatim}
+
+This binds the TAB key to the completion function, so hitting the TAB
+key twice suggests completions; it looks at Python statement names,
+the current local variables, and the available module names.  For
+dotted expressions such as \code{string.a}, it will evaluate the the
+expression up to the final \character{.} and then suggest completions
+from the attributes of the resulting object.  Note that this may
+execute application-defined code if an object with a
+\method{__getattr__()} method is part of the expression.
+
+
 \section{Commentary}
 \label{commentary}