Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
37f1574f
Commit
37f1574f
authored
Nov 10, 1999
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use \citetitle and \programopt as appropriate.
parent
e15eb35f
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
149 additions
and
144 deletions
+149
-144
Doc/lib/lib.tex
Doc/lib/lib.tex
+17
-15
Doc/lib/libcurses.tex
Doc/lib/libcurses.tex
+2
-1
Doc/lib/libexcs.tex
Doc/lib/libexcs.tex
+14
-12
Doc/lib/libimaplib.tex
Doc/lib/libimaplib.tex
+4
-4
Doc/lib/libobjs.tex
Doc/lib/libobjs.tex
+2
-2
Doc/lib/libparser.tex
Doc/lib/libparser.tex
+17
-17
Doc/lib/libsocket.tex
Doc/lib/libsocket.tex
+7
-7
Doc/lib/libsocksvr.tex
Doc/lib/libsocksvr.tex
+2
-2
Doc/lib/libsoundex.tex
Doc/lib/libsoundex.tex
+8
-9
Doc/lib/libstdtypes.tex
Doc/lib/libstdtypes.tex
+21
-17
Doc/lib/libundoc.tex
Doc/lib/libundoc.tex
+3
-2
Doc/lib/libwhrandom.tex
Doc/lib/libwhrandom.tex
+8
-12
Doc/tut/tut.tex
Doc/tut/tut.tex
+44
-44
No files found.
Doc/lib/lib.tex
View file @
37f1574f
...
@@ -30,16 +30,16 @@ Python is an extensible, interpreted, object-oriented programming
...
@@ -30,16 +30,16 @@ Python is an extensible, interpreted, object-oriented programming
language. It supports a wide range of applications, from simple text
language. It supports a wide range of applications, from simple text
processing scripts to interactive WWW browsers.
processing scripts to interactive WWW browsers.
While the
\
emph
{
Python Reference Manual
}
describes the exact syntax and
While the
\
citetitle
[../ref/ref.html]
{
Python Reference Manual
}
semantics of the language, it does not describe the standard library
describes the exact syntax and semantics of the language, it does not
that is distributed with the language, and which greatly enhances its
describe the standard library that is distributed with the language,
immediate usability. This library contains built-in modules (written
and which greatly enhances its immediate usability. This library
in C) that provide access to system functionality such as file I/O
contains built-in modules (written in C) that provide access to system
that would otherwise be inaccessible to Python programmers, as well as
functionality such as file I/O that would otherwise be inaccessible to
modules written in Python that provide standardized solutions for many
Python programmers, as well as modules written in Python that provide
problems that occur in everyday programming. Some of these modules
standardized solutions for many problems that occur in everyday
are explicitly designed to encourage and enhance the portability of
programming. Some of these modules are explicitly designed to
Python programs.
encourage and enhance the portability of
Python programs.
This library reference manual documents Python's standard library, as
This library reference manual documents Python's standard library, as
well as many optional library modules (which may or may not be
well as many optional library modules (which may or may not be
...
@@ -50,11 +50,13 @@ functions and exceptions, many of which are not or incompletely
...
@@ -50,11 +50,13 @@ functions and exceptions, many of which are not or incompletely
documented in the Reference Manual.
documented in the Reference Manual.
This manual assumes basic knowledge about the Python language. For an
This manual assumes basic knowledge about the Python language. For an
informal introduction to Python, see the
\emph
{
Python Tutorial
}
; the
informal introduction to Python, see the
\emph
{
Python Reference Manual
}
remains the highest authority on
\citetitle
[../tut/tut.html]
{
Python Tutorial
}
; the
syntactic and semantic questions. Finally, the manual entitled
\citetitle
[../ref/ref.html]
{
Python Reference Manual
}
remains the
\emph
{
Extending and Embedding the Python Interpreter
}
describes how to
highest authority on syntactic and semantic questions. Finally, the
add new extensions to Python and how to embed it in other applications.
manual entitled
\citetitle
[../ext/ext.html]
{
Extending and Embedding
the Python Interpreter
}
describes how to add new extensions to Python
and how to embed it in other applications.
\end{abstract}
\end{abstract}
...
...
Doc/lib/libcurses.tex
View file @
37f1574f
...
@@ -16,7 +16,8 @@ curses.
...
@@ -16,7 +16,8 @@ curses.
\begin{seealso}
\begin{seealso}
\seetext
{
Tutorial material on using curses with Python is available
\seetext
{
Tutorial material on using curses with Python is available
on the Python Web site as Andrew Kuchling's
\emph
{
Curses
on the Python Web site as Andrew Kuchling's
\citetitle
[http://www.python.org/doc/howto/curses/curses.html]
{
Curses
Programming with Python
}
, at
Programming with Python
}
, at
\url
{
http://www.python.org/doc/howto/curses/curses.html
}
.
}
\url
{
http://www.python.org/doc/howto/curses/curses.html
}
.
}
\end{seealso}
\end{seealso}
...
...
Doc/lib/libexcs.tex
View file @
37f1574f
...
@@ -11,15 +11,17 @@ and users are encouraged to do the same. The source code for those
...
@@ -11,15 +11,17 @@ and users are encouraged to do the same. The source code for those
exceptions is present in the standard library module
exceptions is present in the standard library module
\module
{
exceptions
}
; this module never needs to be imported explicitly.
\module
{
exceptions
}
; this module never needs to be imported explicitly.
For backward compatibility, when Python is invoked with the
\code
{
-X
}
For backward compatibility, when Python is invoked with the
option, most of the standard exceptions are strings
\footnote
{
For
\programopt
{
-X
}
option, most of the standard exceptions are
forward-compatibility the new exceptions
\exception
{
Exception
}
,
strings
\footnote
{
\exception
{
LookupError
}
,
For forward-compatibility the new exceptions
\exception
{
Exception
}
,
\exception
{
ArithmeticError
}
,
\exception
{
EnvironmentError
}
, and
\exception
{
LookupError
}
,
\exception
{
ArithmeticError
}
,
\exception
{
StandardError
}
are tuples.
}
. This option may be used to
\exception
{
EnvironmentError
}
, and
\exception
{
StandardError
}
are
run code that breaks because of the different semantics of class based
tuples.
exceptions. The
\code
{
-X
}
option will become obsolete in future
}
. This option may be used to run code that breaks because of the
Python versions, so the recommended solution is to fix the code.
different semantics of class based exceptions. The
\programopt
{
-X
}
option will become obsolete in future Python versions,
so the recommended solution is to fix the code.
Two distinct string objects with the same value are considered different
Two distinct string objects with the same value are considered different
exceptions. This is done to force programmers to use exception names
exceptions. This is done to force programmers to use exception names
...
@@ -122,8 +124,8 @@ created with other than 2 or 3 arguments. In this last case,
...
@@ -122,8 +124,8 @@ created with other than 2 or 3 arguments. In this last case,
\setindexsubitem
{
(built-in exception)
}
\setindexsubitem
{
(built-in exception)
}
The following exceptions are the exceptions that are actually raised.
The following exceptions are the exceptions that are actually raised.
They are class objects, except when the
\
code
{
-X
}
option is used to
They are class objects, except when the
\
programopt
{
-X
}
option is used
revert back to string-based standard exceptions.
to
revert back to string-based standard exceptions.
\begin{excdesc}
{
AssertionError
}
\begin{excdesc}
{
AssertionError
}
Raised when an
\keyword
{
assert
}
statement fails.
Raised when an
\keyword
{
assert
}
statement fails.
...
@@ -150,7 +152,7 @@ Raised when an \keyword{assert} statement fails.
...
@@ -150,7 +152,7 @@ Raised when an \keyword{assert} statement fails.
\begin{excdesc}
{
FloatingPointError
}
\begin{excdesc}
{
FloatingPointError
}
Raised when a floating point operation fails. This exception is
Raised when a floating point operation fails. This exception is
always defined, but can only be raised when Python is configured
always defined, but can only be raised when Python is configured
with the
\
code
{
-
-with-fpectl
}
option, or the
with the
\
programopt
{
-
}
\programopt
{
-with-fpectl
}
option, or the
\constant
{
WANT
_
SIGFPE
_
HANDLER
}
symbol is defined in the
\constant
{
WANT
_
SIGFPE
_
HANDLER
}
symbol is defined in the
\file
{
config.h
}
file.
\file
{
config.h
}
file.
\end{excdesc}
\end{excdesc}
...
...
Doc/lib/libimaplib.tex
View file @
37f1574f
...
@@ -72,10 +72,10 @@ At the end of the module, there is a test section that contains a more
...
@@ -72,10 +72,10 @@ At the end of the module, there is a test section that contains a more
extensive example of usage.
extensive example of usage.
\begin{seealso}
\begin{seealso}
\seetext
{
Documents describing the protocol, and sources and binaries
\seetext
{
Documents describing the protocol, and sources and binaries
for servers implementing it, can all be found at the University of
for servers implementing it, can all be found at the
Washington's
\emph
{
IMAP Information Center
}
University of
Washington's
\emph
{
IMAP Information Center
}
(
\url
{
http://www.cac.washington.edu/imap/
}
).
}
(
\url
{
http://www.cac.washington.edu/imap/
}
).
}
\end{seealso}
\end{seealso}
...
...
Doc/lib/libobjs.tex
View file @
37f1574f
...
@@ -20,5 +20,5 @@ listing them in order of ascending priority (within a table) and
...
@@ -20,5 +20,5 @@ listing them in order of ascending priority (within a table) and
grouping operators that have the same priority in the same box.
grouping operators that have the same priority in the same box.
Binary operators of the same priority group from left to right.
Binary operators of the same priority group from left to right.
(Unary operators group from right to left, but there you have no real
(Unary operators group from right to left, but there you have no real
choice.) See Chapter 5 of the
\
emph
{
Python Reference Manual
}
for the
choice.) See Chapter 5 of the
\
citetitle
[../ref/ref.html]
{
Python
complete picture on operator priorities.
Reference Manual
}
for the
complete picture on operator priorities.
Doc/lib/libparser.tex
View file @
37f1574f
...
@@ -35,23 +35,23 @@ the \module{parser} module are presented.
...
@@ -35,23 +35,23 @@ the \module{parser} module are presented.
Most importantly, a good understanding of the Python grammar processed
Most importantly, a good understanding of the Python grammar processed
by the internal parser is required. For full information on the
by the internal parser is required. For full information on the
language syntax, refer to the
\
emph
{
Python Language Reference
}
. The
language syntax, refer to the
\
citetitle
[../ref/ref.html]
{
Python
parser itself is created from a grammar specification defined in the file
Language Reference
}
. The parser itself is created from a grammar
\file
{
Grammar/Grammar
}
in the standard Python distribution. The pars
e
specification defined in the file
\file
{
Grammar/Grammar
}
in th
e
trees stored in the AST objects created by this module are the
standard Python distribution. The parse trees stored in the AST
actual output from the internal parser when created by the
objects created by this module are the actual output from the internal
\function
{
expr()
}
or
\function
{
suite()
}
functions, described below. The AST
parser when created by the
\function
{
expr()
}
or
\function
{
suite()
}
objects created by
\function
{
sequence2ast()
}
faithfully simulate those
functions, described below. The AST objects created by
structures. Be aware that the values of the sequences which ar
e
\function
{
sequence2ast()
}
faithfully simulate those structures. B
e
considered ``correct'' will vary from one version of Python to another
aware that the values of the sequences which are considered
as the formal grammar for the language is revised. However,
``correct'' will vary from one version of Python to another as the
transporting code from one Python version to another as source text
formal grammar for the language is revised. However, transporting
will always allow correct parse trees to be created in the target
code from one Python version to another as source text will always
version, with the only restriction being that migrating to an older
allow correct parse trees to be created in the target version, with
version of the interpreter will not support more recent languag
e
the only restriction being that migrating to an older version of th
e
constructs. The parse trees are not typically compatible from on
e
interpreter will not support more recent language constructs. Th
e
version to another, whereas source code has always been
parse trees are not typically compatible from one version to another,
forward-compatible.
whereas source code has always been
forward-compatible.
Each element of the sequences returned by
\function
{
ast2list()
}
or
Each element of the sequences returned by
\function
{
ast2list()
}
or
\function
{
ast2tuple()
}
has a simple form. Sequences representing
\function
{
ast2tuple()
}
has a simple form. Sequences representing
...
...
Doc/lib/libsocket.tex
View file @
37f1574f
...
@@ -9,13 +9,13 @@ This module provides access to the BSD \emph{socket} interface.
...
@@ -9,13 +9,13 @@ This module provides access to the BSD \emph{socket} interface.
It is available on
\UNIX
{}
systems that support this interface.
It is available on
\UNIX
{}
systems that support this interface.
For an introduction to socket programming (in C), see the following
For an introduction to socket programming (in C), see the following
papers:
\
emph
{
An Introductory 4.3BSD Interprocess Communication
papers:
\
citetitle
{
An Introductory 4.3BSD Interprocess Communication
Tutorial
}
, by Stuart Sechrest and
\
emph
{
An Advanced 4.3BSD Interprocess
Tutorial
}
, by Stuart Sechrest and
\
citetitle
{
An Advanced 4.3BSD
Communication Tutorial
}
, by Samuel J. Leffler et al, both in the
Interprocess Communication Tutorial
}
, by Samuel J. Leffler et al,
\UNIX
{}
Programmer's Manual, Supplementary Documents 1 (sections PS1:7
both in the
\citetitle
{
\UNIX
{}
Programmer's Manual, Supplementary Documents 1
}
and PS1:8). The
\UNIX
{}
manual pages for the various socket-related
(sections PS1:7 and PS1:8). The
\UNIX
{}
manual pages for the various
s
ystem calls are also a valuable source of information on the details of
s
ocket-related system calls are also a valuable source of information
socket semantics.
on the details of
socket semantics.
The Python interface is a straightforward transliteration of the
The Python interface is a straightforward transliteration of the
\UNIX
{}
system call and library interface for sockets to Python's
\UNIX
{}
system call and library interface for sockets to Python's
...
...
Doc/lib/libsocksvr.tex
View file @
37f1574f
...
@@ -16,8 +16,8 @@ lost while in transit. The more infrequently used
...
@@ -16,8 +16,8 @@ lost while in transit. The more infrequently used
\class
{
UnixStreamServer
}
and
\class
{
UnixDatagramServer
}
classes are
\class
{
UnixStreamServer
}
and
\class
{
UnixDatagramServer
}
classes are
similar, but use
\UNIX
{}
domain sockets; they're not available on
similar, but use
\UNIX
{}
domain sockets; they're not available on
non-
\UNIX
{}
platforms. For more details on network programming, consult
non-
\UNIX
{}
platforms. For more details on network programming, consult
a book such as W. Richard Steven's
\
emph
{
UNIX Network Programming
}
a book such as W. Richard Steven's
\
citetitle
{
UNIX Network Programming
}
or Ralph Davis's
\
emph
{
Win32 Network Programming
}
.
or Ralph Davis's
\
citetitle
{
Win32 Network Programming
}
.
These four classes process requests
\dfn
{
synchronously
}
; each request
These four classes process requests
\dfn
{
synchronously
}
; each request
must be completed before the next request can be started. This isn't
must be completed before the next request can be started. This isn't
...
...
Doc/lib/libsoundex.tex
View file @
37f1574f
...
@@ -32,13 +32,12 @@ is equivalent to
...
@@ -32,13 +32,12 @@ is equivalent to
\begin{seealso}
\begin{seealso}
\seetext
{
Donald E. Knuth,
\citetitle
{
Sorting and Searching
}
, vol. 3
\seetext
{
Donald E. Knuth,
\emph
{
Sorting and Searching,
}
vol. 3 in
in ``The Art of Computer Programming.'' Addison-Wesley
``The Art of Computer Programming.'' Addison-Wesley Publishing
Publishing Company: Reading, MA: 1973. pp.
\
391-392.
Company: Reading, MA: 1973. pp.
\
391-392. Discusses the origin and
Discusses the origin and usefulness of the algorithm, as
usefulness of the algorithm, as well as the algorithm itself. Knuth
well as the algorithm itself. Knuth gives his sources as
gives his sources as
\emph
{
U.S. Patents 1261167
}
(1918) and
\emph
{
U.S. Patents 1261167
}
(1918) and
\emph
{
1435663
}
\emph
{
1435663
}
(1922), attributing the algorithm to Margaret K. Odell
(1922), attributing the algorithm to Margaret K. Odell and
and Robert C. Russel. Additional references are provided.
}
Robert C. Russel. Additional references are provided.
}
\end{seealso}
\end{seealso}
Doc/lib/libstdtypes.tex
View file @
37f1574f
...
@@ -302,14 +302,14 @@ division by \code{pow(2, \var{n})} without overflow check.
...
@@ -302,14 +302,14 @@ division by \code{pow(2, \var{n})} without overflow check.
There are three sequence types: strings, lists and tuples.
There are three sequence types: strings, lists and tuples.
Strings literals are written in single or double quotes:
Strings literals are written in single or double quotes:
\code
{
'xyzzy'
}
,
\code
{
"frobozz"
}
. See Chapter 2 of the
\emph
{
Python
\code
{
'xyzzy'
}
,
\code
{
"frobozz"
}
. See Chapter 2 of the
Reference Manual
}
for more about string literals. Lists are
\citetitle
[../ref/ref.html]
{
Python Reference Manual
}
for more about
constructed with square brackets, separating items with commas:
string literals. Lists are constructed with square brackets,
\code
{
[a, b, c]
}
. Tuples are constructed by the comma operator (not
separating items with commas:
\code
{
[a, b, c]
}
. Tuples are
within square brackets), with or without enclosing parentheses, but an
constructed by the comma operator (not within square brackets), with
empty tuple must have the enclosing parentheses, e.g.,
or without enclosing parentheses, but an empty tuple must have the
\code
{
a, b, c
}
or
\code
{
()
}
. A single item tuple must have a trailing
enclosing parentheses, e.g.,
\code
{
a, b, c
}
or
\code
{
()
}
. A single
comma, e.g.,
\code
{
(d,)
}
.
item tuple must have a trailing
comma, e.g.,
\code
{
(d,)
}
.
\indexii
{
sequence
}{
types
}
\indexii
{
sequence
}{
types
}
\indexii
{
string
}{
type
}
\indexii
{
string
}{
type
}
\indexii
{
tuple
}{
type
}
\indexii
{
tuple
}{
type
}
...
@@ -629,7 +629,8 @@ written as \code{<module 'os' from '/usr/local/lib/python1.5/os.pyc'>}.
...
@@ -629,7 +629,8 @@ written as \code{<module 'os' from '/usr/local/lib/python1.5/os.pyc'>}.
\subsubsection
{
Classes and Class Instances
\label
{
typesobjects
}}
\subsubsection
{
Classes and Class Instances
\label
{
typesobjects
}}
\nodename
{
Classes and Instances
}
\nodename
{
Classes and Instances
}
See Chapters 3 and 7 of the
\emph
{
Python Reference Manual
}
for these.
See Chapters 3 and 7 of the
\citetitle
[../ref/ref.html]
{
Python
Reference Manual
}
for these.
\subsubsection
{
Functions
\label
{
typesfunctions
}}
\subsubsection
{
Functions
\label
{
typesfunctions
}}
...
@@ -667,7 +668,8 @@ implementing the method. Calling \code{\var{m}(\var{arg-1},
...
@@ -667,7 +668,8 @@ implementing the method. Calling \code{\var{m}(\var{arg-1},
calling
\code
{
\var
{
m
}
.im
_
func(
\var
{
m
}
.im
_
self,
\var
{
arg-1
}
,
calling
\code
{
\var
{
m
}
.im
_
func(
\var
{
m
}
.im
_
self,
\var
{
arg-1
}
,
\var
{
arg-2
}
,
\textrm
{
\ldots
}
,
\var
{
arg-n
}
)
}
.
\var
{
arg-2
}
,
\textrm
{
\ldots
}
,
\var
{
arg-n
}
)
}
.
See the
\emph
{
Python Reference Manual
}
for more information.
See the
\citetitle
[../ref/ref.html]
{
Python Reference Manual
}
for more
information.
\subsubsection
{
Code Objects
\label
{
bltin-code-objects
}}
\subsubsection
{
Code Objects
\label
{
bltin-code-objects
}}
...
@@ -689,7 +691,8 @@ source string) to the \keyword{exec} statement or the built-in
...
@@ -689,7 +691,8 @@ source string) to the \keyword{exec} statement or the built-in
\stindex
{
exec
}
\stindex
{
exec
}
\bifuncindex
{
eval
}
\bifuncindex
{
eval
}
See the
\emph
{
Python Reference Manual
}
for more information.
See the
\citetitle
[../ref/ref.html]
{
Python Reference Manual
}
for more
information.
\subsubsection
{
Type Objects
\label
{
bltin-type-objects
}}
\subsubsection
{
Type Objects
\label
{
bltin-type-objects
}}
...
@@ -715,9 +718,10 @@ It is written as \code{None}.
...
@@ -715,9 +718,10 @@ It is written as \code{None}.
\subsubsection
{
The Ellipsis Object
\label
{
bltin-ellipsis-object
}}
\subsubsection
{
The Ellipsis Object
\label
{
bltin-ellipsis-object
}}
This object is used by extended slice notation (see the
\emph
{
Python
This object is used by extended slice notation (see the
Reference Manual
}
). It supports no special operations. There is
\citetitle
[../ref/ref.html]
{
Python Reference Manual
}
). It supports no
exactly one ellipsis object, named
\code
{
Ellipsis
}
(a built-in name).
special operations. There is exactly one ellipsis object, named
\constant
{
Ellipsis
}
(a built-in name).
It is written as
\code
{
Ellipsis
}
.
It is written as
\code
{
Ellipsis
}
.
...
@@ -868,9 +872,9 @@ attribute.
...
@@ -868,9 +872,9 @@ attribute.
\subsubsection
{
Internal Objects
\label
{
typesinternal
}}
\subsubsection
{
Internal Objects
\label
{
typesinternal
}}
See the
\
emph
{
Python Reference Manual
}
for this information. It
See the
\
citetitle
[../ref/ref.html]
{
Python Reference Manual
}
for this
describes code objects, stack frame objects, traceback objects, and
information. It describes code objects, stack frame objects,
slice objects.
traceback objects, and
slice objects.
\subsection
{
Special Attributes
\label
{
specialattrs
}}
\subsection
{
Special Attributes
\label
{
specialattrs
}}
...
...
Doc/lib/libundoc.tex
View file @
37f1574f
...
@@ -14,8 +14,9 @@ effort spent.
...
@@ -14,8 +14,9 @@ effort spent.
\begin{description}
\begin{description}
\item
[\module{Tkinter}]
\item
[\module{Tkinter}]
--- Interface to Tcl/Tk for graphical user interfaces;
--- Interface to Tcl/Tk for graphical user interfaces; Fredrik Lundh
Fredrik Lundh is working on this one! See
\emph
{
An Introduction to
is working on this one! See
\citetitle
[http://www.pythonware.com/library/]
{
An Introduction to
Tkinter
}
at
\url
{
http://www.pythonware.com/library/
}
for on-line
Tkinter
}
at
\url
{
http://www.pythonware.com/library/
}
for on-line
reference material.
reference material.
...
...
Doc/lib/libwhrandom.tex
View file @
37f1574f
...
@@ -22,13 +22,9 @@ Returns the next random floating point number in the range [0.0 ... 1.0).
...
@@ -22,13 +22,9 @@ Returns the next random floating point number in the range [0.0 ... 1.0).
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}
{
seed
}{
x, y, z
}
\begin{funcdesc}
{
seed
}{
x, y, z
}
Initializes the random number generator from the integers
Initializes the random number generator from the integers
\var
{
x
}
,
\var
{
x
}
,
\var
{
y
}
and
\var
{
z
}
. When the module is first imported, the random
\var
{
y
}
number is initialized using values derived from the current time.
and
\var
{
z
}
.
When the module is first imported, the random number is initialized
using values derived from the current time.
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}
{
uniform
}{
a, b
}
\begin{funcdesc}
{
uniform
}{
a, b
}
...
@@ -43,10 +39,10 @@ available at the module level. Therefore one can write either
...
@@ -43,10 +39,10 @@ available at the module level. Therefore one can write either
generator = whrandom.whrandom()
generator = whrandom.whrandom()
N = generator.random()
N = generator.random()
\end{verbatim}
\end{verbatim}
%
\begin{seealso}
\begin{seealso}
\seemodule
{
random
}{
generators for various random distributions
}
\seemodule
{
random
}{
generators for various random distributions
}
\seetext
{
Wichmann, B. A.
\&
Hill, I. D., ``Algorithm AS 183:
\seetext
{
Wichmann, B. A.
\&
Hill, I. D., ``Algorithm AS 183:
An efficient and portable pseudo-random number generator'',
An efficient and portable pseudo-random number generator'',
\emph
{
Applied Statistics
}
31 (1982) 188-190
}
\citetitle
{
Applied Statistics
}
31 (1982) 188-190.
}
\end{seealso}
\end{seealso}
Doc/tut/tut.tex
View file @
37f1574f
...
@@ -48,11 +48,12 @@ Python interpreter handy for hands-on experience, but all examples are
...
@@ -48,11 +48,12 @@ Python interpreter handy for hands-on experience, but all examples are
self-contained, so the tutorial can be read off-line as well.
self-contained, so the tutorial can be read off-line as well.
For a description of standard objects and modules, see the
For a description of standard objects and modules, see the
\emph
{
Python Library Reference
}
document. The
\emph
{
Python Reference
\citetitle
[../lib/lib.html]
{
Python Library Reference
}
document. The
Manual
}
gives a more formal definition of the language. To write
\citetitle
[../ref/ref.html]
{
Python Reference Manual
}
gives a more
extensions in C or
\Cpp
{}
, read the
\emph
{
Extending and Embedding
}
and
formal definition of the language. To write extensions in C or
\emph
{
Python/C API
}
manuals. There are also several books covering
\Cpp
{}
, read
\citetitle
[../ext/ext.html]
{
Extending and Embedding the
Python in depth.
Python Interpreter
}
and
\citetitle
[../api/api.html]
{
Python/C API
Reference
}
. There are also several books covering Python in depth.
This tutorial does not attempt to be comprehensive and cover every
This tutorial does not attempt to be comprehensive and cover every
single feature, or even every commonly used feature. Instead, it
single feature, or even every commonly used feature. Instead, it
...
@@ -60,7 +61,8 @@ introduces many of Python's most noteworthy features, and will give
...
@@ -60,7 +61,8 @@ introduces many of Python's most noteworthy features, and will give
you a good idea of the language's flavor and style. After reading it,
you a good idea of the language's flavor and style. After reading it,
you will be able to read and write Python modules and programs, and
you will be able to read and write Python modules and programs, and
you will be ready to learn more about the various Python library
you will be ready to learn more about the various Python library
modules described in the
\emph
{
Python Library Reference
}
.
modules described in the
\citetitle
[../lib/lib.html]
{
Python Library
Reference
}
.
\end{abstract}
\end{abstract}
...
@@ -196,11 +198,11 @@ a file as standard input, it reads and executes a \emph{script} from
...
@@ -196,11 +198,11 @@ a file as standard input, it reads and executes a \emph{script} from
that file.
that file.
A third way of starting the interpreter is
A third way of starting the interpreter is
\samp
{
python -c command
[arg] ...
}
, which
\samp
{
\program
{
python
}
\programopt
{
-c
}
\var
{
command
}
[arg] ...
}
, which
executes the statement(s) in
\
code
{
command
}
, analogous to the shell's
executes the statement(s) in
\
var
{
command
}
, analogous to the shell's
\
code
{
-c
}
option. Since Python statements often contain spaces or other
\
programopt
{
-c
}
option. Since Python statements often contain spaces
characters that are special to the shell, it is best to quote
or other characters that are special to the shell, it is best to quote
\
code
{
command
}
in its entirety with double quotes.
\
var
{
command
}
in its entirety with double quotes.
Note that there is a difference between
\samp
{
python file
}
and
Note that there is a difference between
\samp
{
python file
}
and
\samp
{
python <file
}
. In the latter case, input requests from the
\samp
{
python <file
}
. In the latter case, input requests from the
...
@@ -213,9 +215,9 @@ is connected to standard input of the Python interpreter.
...
@@ -213,9 +215,9 @@ is connected to standard input of the Python interpreter.
When a script file is used, it is sometimes useful to be able to run
When a script file is used, it is sometimes useful to be able to run
the script and enter interactive mode afterwards. This can be done by
the script and enter interactive mode afterwards. This can be done by
passing
\
code
{
-i
}
before the script. (This does not work if the script
passing
\
programopt
{
-i
}
before the script. (This does not work if the
is read from standard input, for the same reason as explained in the
script is read from standard input, for the same reason as explained
previous paragraph.)
in the
previous paragraph.)
\subsection
{
Argument Passing
\label
{
argPassing
}}
\subsection
{
Argument Passing
\label
{
argPassing
}}
...
@@ -224,11 +226,11 @@ arguments thereafter are passed to the script in the variable
...
@@ -224,11 +226,11 @@ arguments thereafter are passed to the script in the variable
\code
{
sys.argv
}
, which is a list of strings. Its length is at least
\code
{
sys.argv
}
, which is a list of strings. Its length is at least
one; when no script and no arguments are given,
\code
{
sys.argv[0]
}
is
one; when no script and no arguments are given,
\code
{
sys.argv[0]
}
is
an empty string. When the script name is given as
\code
{
'-'
}
(meaning
an empty string. When the script name is given as
\code
{
'-'
}
(meaning
standard input),
\code
{
sys.argv[0]
}
is set to
\code
{
'-'
}
. When
\code
{
-c
standard input),
\code
{
sys.argv[0]
}
is set to
\code
{
'-'
}
. When
command
}
is used,
\code
{
sys.argv[0]
}
is set to
\code
{
'-c'
}
. Options
\programopt
{
-c
}
\var
{
command
}
is used,
\code
{
sys.argv[0]
}
is set to
found after
\code
{
-c command
}
are not consumed by the Python
\code
{
'-c'
}
. Options found after
\programopt
{
-c
}
\var
{
command
}
are
interpreter's option processing but left in
\code
{
sys.argv
}
for the
not consumed by the Python interpreter's option processing but left in
command to handle.
\code
{
sys.argv
}
for the
command to handle.
\subsection
{
Interactive Mode
\label
{
interactive
}}
\subsection
{
Interactive Mode
\label
{
interactive
}}
...
@@ -1845,11 +1847,9 @@ If you intend to use a function often you can assign it to a local name:
...
@@ -1845,11 +1847,9 @@ If you intend to use a function often you can assign it to a local name:
\section
{
More on Modules
\label
{
moreModules
}}
\section
{
More on Modules
\label
{
moreModules
}}
A module can contain executable statements as well as function
A module can contain executable statements as well as function
definitions.
definitions. These statements are intended to initialize the module.
These statements are intended to initialize the module.
They are executed only the
\emph
{
first
}
time the module is imported
They are executed only the
somewhere.
\footnote
{
\emph
{
first
}
time the module is imported somewhere.
\footnote
{
In fact function definitions are also `statements' that are
In fact function definitions are also `statements' that are
`executed'; the execution enters the function name in the
`executed'; the execution enters the function name in the
module's global symbol table.
module's global symbol table.
...
@@ -1944,22 +1944,22 @@ Some tips for experts:
...
@@ -1944,22 +1944,22 @@ Some tips for experts:
\begin{itemize}
\begin{itemize}
\item
\item
When the Python interpreter is invoked with the
\
code
{
-O
}
flag,
When the Python interpreter is invoked with the
\
programopt
{
-O
}
flag,
optimized code is generated and stored in
\file
{
.pyo
}
files.
optimized code is generated and stored in
\file
{
.pyo
}
files.
The optimizer currently doesn't help much; it only removes
The optimizer currently doesn't help much; it only removes
\keyword
{
assert
}
statements and
\code
{
SET
_
LINENO
}
instructions.
\keyword
{
assert
}
statements and
\code
{
SET
_
LINENO
}
instructions.
When
\
code
{
-O
}
is used,
\emph
{
all
}
bytecode is optimized;
\code
{
.pyc
}
When
\
programopt
{
-O
}
is used,
\emph
{
all
}
bytecode is optimized;
files are ignored and
\code
{
.py
}
files are compiled to optimized
\code
{
.pyc
}
files are ignored and
\code
{
.py
}
files are compiled to
bytecode.
optimized
bytecode.
\item
\item
Passing two
\
code
{
-O
}
flags to the Python interpreter (
\code
{
-OO
}
)
Passing two
\
programopt
{
-O
}
flags to the Python interpreter
will cause the bytecode compiler to perform optimizations that could
(
\programopt
{
-OO
}
) will cause the bytecode compiler to perform
in some rare cases result in malfunctioning programs. Currently only
optimizations that could in some rare cases result in malfunctioning
\code
{__
doc
__}
strings are removed from the bytecode, resulting in more
programs. Currently only
\code
{__
doc
__}
strings are removed from the
compact
\file
{
.pyo
}
files. Since some programs may rely on having
bytecode, resulting in more compact
\file
{
.pyo
}
files. Since some
these available, you should only use this option if you know what
programs may rely on having these available, you should only use this
you're doing.
option if you know what
you're doing.
\item
\item
A program doesn't run any faster when it is read from a
A program doesn't run any faster when it is read from a
...
@@ -1976,14 +1976,14 @@ script that imports that module.
...
@@ -1976,14 +1976,14 @@ script that imports that module.
\item
\item
It is possible to have a file called
\file
{
spam.pyc
}
(or
It is possible to have a file called
\file
{
spam.pyc
}
(or
\file
{
spam.pyo
}
when
\
code
{
-O
}
is used) without a module
\file
{
spam.pyo
}
when
\
programopt
{
-O
}
is used) without a module
\file
{
spam.py
}
in the same module. This can be used to distribute
\file
{
spam.py
}
in the same module. This can be used to distribute
a library of Python code in a form that is moderately hard to reverse
a library of Python code in a form that is moderately hard to reverse
engineer.
engineer.
\item
\item
The module
\module
{
compileall
}
\refstmodindex
{
compileall
}
can create
The module
\module
{
compileall
}
\refstmodindex
{
compileall
}
can create
\file
{
.pyc
}
files (or
\file
{
.pyo
}
files when
\
code
{
-O
}
is used) for
\file
{
.pyc
}
files (or
\file
{
.pyo
}
files when
\
programopt
{
-O
}
is used) for
all modules in a directory.
all modules in a directory.
\end{itemize}
\end{itemize}
...
@@ -1992,13 +1992,13 @@ all modules in a directory.
...
@@ -1992,13 +1992,13 @@ all modules in a directory.
\section
{
Standard Modules
\label
{
standardModules
}}
\section
{
Standard Modules
\label
{
standardModules
}}
Python comes with a library of standard modules, described in a separate
Python comes with a library of standard modules, described in a separate
document, the
\
emph
{
Python Library Reference
}
(``Library Reference''
document, the
\
citetitle
[../lib/lib.html]
{
Python Library Reference
}
hereafter). Some modules are built into the interpreter; thes
e
(``Library Reference'' hereafter). Some modules are built into th
e
provide access to operations that are not part of the core of the
interpreter; these provide access to operations that are not part of
language but are nevertheless built in, either for efficiency or to
the core of the language but are nevertheless built in, either for
provide access to operating system primitives such as system calls.
efficiency or to provide access to operating system primitives such as
The set of such modules is a configuration option; e.g., the
system calls. The set of such modules is a configuration option; e.g.,
\module
{
amoeba
}
module is
only provided on systems that somehow
the
\module
{
amoeba
}
module is
only provided on systems that somehow
support Amoeba primitives. One particular module deserves some
support Amoeba primitives. One particular module deserves some
attention:
\module
{
sys
}
\refstmodindex
{
sys
}
, which is built into every
attention:
\module
{
sys
}
\refstmodindex
{
sys
}
, which is built into every
Python interpreter. The variables
\code
{
sys.ps1
}
and
Python interpreter. The variables
\code
{
sys.ps1
}
and
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment