]> granicus.if.org Git - python/commitdiff
added code.py; codehack.py is obsolete
authorGuido van Rossum <guido@python.org>
Fri, 18 Jul 1997 21:08:07 +0000 (21:08 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 18 Jul 1997 21:08:07 +0000 (21:08 +0000)
Doc/Makefile
Doc/lib.tex
Doc/lib/lib.tex
Doc/lib/libcode.tex [new file with mode: 0644]
Doc/lib/libundoc.tex
Doc/libcode.tex [new file with mode: 0644]
Doc/libundoc.tex

index 1d6823466e819c1bc23b62acf03ce6b62c06a6be..867148fe9be6e0f4e8cfc17ab95251e9a37833c4 100644 (file)
@@ -112,7 +112,7 @@ LIBFILES = lib.tex \
     libuser.tex libanydbm.tex librandom.tex libsite.tex libwhichdb.tex \
     libbase64.tex libfnmatch.tex libquopri.tex libzlib.tex libsocksvr.tex \
     libmailbox.tex libcommands.tex libcmath.tex libni.tex libgzip.tex \
-    libpprint.tex
+    libpprint.tex libcode.tex
 
 # Library document
 lib.dvi: $(LIBFILES)
index 391c241ff869b1cadab08399491db536acd2d714..2c7d6d0f1cdb42fa56cf7bf8a649fda884441f72 100644 (file)
@@ -88,6 +88,7 @@ to Python and how to embed it in other applications.
 \input{libni}
 \input{libparser}
 \input{libpprint}
+\input{libcode}
 \input{libsite}
 \input{libbltin}               % really __builtin__
 \input{libmain}                        % really __main__
index 391c241ff869b1cadab08399491db536acd2d714..2c7d6d0f1cdb42fa56cf7bf8a649fda884441f72 100644 (file)
@@ -88,6 +88,7 @@ to Python and how to embed it in other applications.
 \input{libni}
 \input{libparser}
 \input{libpprint}
+\input{libcode}
 \input{libsite}
 \input{libbltin}               % really __builtin__
 \input{libmain}                        % really __main__
diff --git a/Doc/lib/libcode.tex b/Doc/lib/libcode.tex
new file mode 100644 (file)
index 0000000..5fa9717
--- /dev/null
@@ -0,0 +1,35 @@
+% Template for a library manual section.
+
+\section{Standard module \sectcode{code}}
+\label{module-code}
+\stmodindex{code}
+
+The \code{code} module defines operations pertaining to Python code
+objects.
+
+The \code{code} module defines the following functions:
+
+\renewcommand{\indexsubitem}{(in module code)}
+
+\begin{funcdesc}{compile_command}{source\,
+\optional{filename\optional{\, symbol}}}
+This function is useful for programs that want to emulate Python's
+interpreter main loop (a.k.a. the read-eval-print loop).  The tricky
+part is to determine when the user has entered an incomplete command
+that can be completed by entering more text (as opposed to a complete
+command or a syntax error).  This function \emph{almost} always makes
+the same decision as the real interpreter main loop.
+
+Arguments: \var{source} is the source string; \var{filename} is the
+optional filename from which source was read, defaulting to
+\code{"<input>"}; and \var{symbol} is the optional grammar start
+symbol, which should be either \code{"single"} (the default) or
+\code{"eval"}.
+
+Return a code object (the same as \code{compile(\var{source},
+\var{filename}, \var{symbol})}) if the command is complete and valid;
+return \code{None} if the command is incomplete; raise
+\code{SyntaxError} if the command is a syntax error.
+
+
+\end{funcdesc}
index 08e62fb3d0f84f1c74ffdd726c94d221ee09c459..55f30a9cac5545d0bc2849eabdac804723cd701e 100644 (file)
@@ -105,8 +105,6 @@ compileall.py -- force "compilation" of all .py files in a directory
 
 py_compile.py -- "compile" a .py file to a .pyc file
 
-codehack.py -- extract a function name from a code object
-
 dis.py -- Disassembler for Python bytecode objects
 
 repr.py -- Redo the `...` (representation) but with limits on most
@@ -183,6 +181,10 @@ fcntl.lockf/flock intead)
 tb.py -- Print tracebacks, with a dump of local variables (use
 pdb.pm() or traceback.py instead)
 
+codehack.py -- extract function name or line number from a function
+code object (these are now accessible as attributes: co.co_name,
+func.func_name, co.co_firstlineno)
+
 
 \section{Extension modules}
 
diff --git a/Doc/libcode.tex b/Doc/libcode.tex
new file mode 100644 (file)
index 0000000..5fa9717
--- /dev/null
@@ -0,0 +1,35 @@
+% Template for a library manual section.
+
+\section{Standard module \sectcode{code}}
+\label{module-code}
+\stmodindex{code}
+
+The \code{code} module defines operations pertaining to Python code
+objects.
+
+The \code{code} module defines the following functions:
+
+\renewcommand{\indexsubitem}{(in module code)}
+
+\begin{funcdesc}{compile_command}{source\,
+\optional{filename\optional{\, symbol}}}
+This function is useful for programs that want to emulate Python's
+interpreter main loop (a.k.a. the read-eval-print loop).  The tricky
+part is to determine when the user has entered an incomplete command
+that can be completed by entering more text (as opposed to a complete
+command or a syntax error).  This function \emph{almost} always makes
+the same decision as the real interpreter main loop.
+
+Arguments: \var{source} is the source string; \var{filename} is the
+optional filename from which source was read, defaulting to
+\code{"<input>"}; and \var{symbol} is the optional grammar start
+symbol, which should be either \code{"single"} (the default) or
+\code{"eval"}.
+
+Return a code object (the same as \code{compile(\var{source},
+\var{filename}, \var{symbol})}) if the command is complete and valid;
+return \code{None} if the command is incomplete; raise
+\code{SyntaxError} if the command is a syntax error.
+
+
+\end{funcdesc}
index 08e62fb3d0f84f1c74ffdd726c94d221ee09c459..55f30a9cac5545d0bc2849eabdac804723cd701e 100644 (file)
@@ -105,8 +105,6 @@ compileall.py -- force "compilation" of all .py files in a directory
 
 py_compile.py -- "compile" a .py file to a .pyc file
 
-codehack.py -- extract a function name from a code object
-
 dis.py -- Disassembler for Python bytecode objects
 
 repr.py -- Redo the `...` (representation) but with limits on most
@@ -183,6 +181,10 @@ fcntl.lockf/flock intead)
 tb.py -- Print tracebacks, with a dump of local variables (use
 pdb.pm() or traceback.py instead)
 
+codehack.py -- extract function name or line number from a function
+code object (these are now accessible as attributes: co.co_name,
+func.func_name, co.co_firstlineno)
+
 
 \section{Extension modules}