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

Skip to content

Commit 571391b

Browse files
committed
New stuff by AMK.
1 parent 6191551 commit 571391b

19 files changed

Lines changed: 401 additions & 41 deletions

Doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ LIBFILES = lib.tex \
114114
librestricted.tex librexec.tex libbastion.tex \
115115
libformatter.tex liboperator.tex libsoundex.tex libresource.tex \
116116
libstat.tex libstrio.tex libundoc.tex libmailcap.tex libglob.tex \
117-
libuser.tex
117+
libuser.tex libanydbm.tex librandom.tex libsite.tex libwhichdb.tex
118118

119119
# Library document
120120
lib.dvi: $(LIBFILES)

Doc/lib.tex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
\input{libmarshal}
8787
\input{libimp}
8888
\input{libparser}
89+
\input{libsite}
8990
\input{libbltin} % really __builtin__
9091
\input{libmain} % really __main__
9192

@@ -99,8 +100,9 @@
99100

100101
\input{libmisc} % Miscellaneous Services
101102
\input{libmath}
102-
\input{librand}
103103
\input{libwhrandom}
104+
\input{librandom}
105+
\input{librand}
104106
\input{libarray}
105107

106108
\input{liballos} % Generic Operating System Services
@@ -116,6 +118,8 @@
116118
\input{libsocket}
117119
\input{libselect}
118120
\input{libthread}
121+
\input{libanydbm}
122+
\input{libwhichdb}
119123

120124
\input{libunix} % UNIX Specific Services
121125
\input{libposix}

Doc/lib/lib.tex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
\input{libmarshal}
8787
\input{libimp}
8888
\input{libparser}
89+
\input{libsite}
8990
\input{libbltin} % really __builtin__
9091
\input{libmain} % really __main__
9192

@@ -99,8 +100,9 @@
99100

100101
\input{libmisc} % Miscellaneous Services
101102
\input{libmath}
102-
\input{librand}
103103
\input{libwhrandom}
104+
\input{librandom}
105+
\input{librand}
104106
\input{libarray}
105107

106108
\input{liballos} % Generic Operating System Services
@@ -116,6 +118,8 @@
116118
\input{libsocket}
117119
\input{libselect}
118120
\input{libthread}
121+
\input{libanydbm}
122+
\input{libwhichdb}
119123

120124
\input{libunix} % UNIX Specific Services
121125
\input{libposix}

Doc/lib/libanydbm.tex

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
\section{Standard Module \sectcode{anydbm}}
2+
\stmodindex{anydbm}
3+
\stmodindex{dumbdbm}
4+
5+
\code{anydbm} is a generic interface to variants of the DBM
6+
database--DBM, GDBM, or dbhash. If none of these modules is
7+
installed, the slow-but-simple implementation in \file{dumbdbm.py}
8+
will be used.
9+
10+
\begin{funcdesc}{open}{filename\optional{\, flag\, mode}}
11+
Open the database file \var{filename} and return a corresponding object.
12+
The optional \var{flag} argument can be
13+
\code{'r'} to open an existing database for reading only,
14+
\code{'w'} to open an existing database for reading and writing,
15+
\code{'c'} to create the database if it doesn't exist, or
16+
\code{'n'}, which will always create a new empty database. If not
17+
specified, the default value is \code{'r'}.
18+
19+
The optional \var{mode} argument is the \UNIX{} mode of the file, used
20+
only when the database has to be created. It defaults to octal
21+
\code{0666}.
22+
\end{funcdesc}
23+
24+
THe object returned by \code{open()} supports most of the same
25+
functionality as dictionaries; keys and their corresponding values can
26+
be stored, retrieved, and deleted, and the \code{has_key()} and
27+
\code{keys()} methods are available. Keys and values must always be strings.
28+
29+

Doc/lib/libmisc.tex

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ \chapter{Miscellaneous Services}
88
\item[math]
99
--- Mathematical functions (\code{sin()} etc.).
1010

11-
\item[rand]
12-
--- Integer random number generator.
13-
1411
\item[whrandom]
15-
--- Floating point random number generator.
12+
--- Floating point pseudo-random number generator.
13+
14+
\item[random]
15+
--- Generate pseudo-random numbers with various common distributions.
16+
17+
\item[rand]
18+
--- Integer pseudo-random number generator (obsolete).
1619

1720
\item[array]
1821
--- Efficient arrays of uniformly typed numeric values.

Doc/lib/librand.tex

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
\section{Standard Module \sectcode{rand}}
2+
\stmodindex{rand}
23

3-
\stmodindex{rand} This module implements a pseudo-random number
4-
generator with an interface similar to \code{rand()} in C\@. It defines
5-
the following functions:
4+
The \code{rand} module simulates the C library's \code{rand()}
5+
interface, though the results aren't necessarily compatible with any
6+
given library's implementation. While still supported for
7+
compatibility, the \code{rand} module is now considered obsolete; if
8+
possible, use the \code{whrandom} module instead.
69

7-
\renewcommand{\indexsubitem}{(in module rand)}
8-
\begin{funcdesc}{rand}{}
9-
Returns an integer random number in the range [0 ... 32768).
10+
\begin{funcdesc}{choice}{seq}
11+
Returns a random element from the sequence \var{seq}.
1012
\end{funcdesc}
1113

12-
\begin{funcdesc}{choice}{s}
13-
Returns a random element from the sequence (string, tuple or list)
14-
\var{s}.
14+
\begin{funcdesc}{rand}{}
15+
Return a random integer between 0 and 32767, inclusive.
1516
\end{funcdesc}
1617

1718
\begin{funcdesc}{srand}{seed}
18-
Initializes the random number generator with the given integral seed.
19-
When the module is first imported, the random number is initialized with
20-
the current time.
19+
Set a starting seed value for the random number generator; \var{seed}
20+
can be an arbitrary integer.
2121
\end{funcdesc}
22+

Doc/lib/librandom.tex

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
\section{Standard Module \sectcode{random}}
2+
\stmodindex{random}
3+
4+
This module implements pseudo-random number generators for various
5+
distributions: on the real line, there are functions to compute normal
6+
or Gaussian, lognormal, negative exponential, gamma, and beta
7+
distributions. For generating distribution of angles, the circular
8+
uniform and von Mises distributions are available.
9+
10+
The module exports the following functions, which are exactly
11+
equivalent to those in the \code{whrandom} module: \code{choice},
12+
\code{randint}, \code{random}, \code{uniform}. See the documentation
13+
for the \code{whrandom} module for these functions.
14+
15+
The following functions specific to the \code{random} module are also
16+
defined, and all return real values. Function parameters are named
17+
after the corresponding variables in the distribution's equation, as
18+
used in common mathematical practice; most of these equations can be
19+
found in any statistics text.
20+
21+
\renewcommand{\indexsubitem}{(in module random)}
22+
\begin{funcdesc}{betavariate}{alpha\, beta}
23+
Beta distribution. Conditions on the parameters are \code{alpha>-1}
24+
and \code{beta>-1}.
25+
Returned values will range between 0 and 1.
26+
\end{funcdesc}
27+
28+
\begin{funcdesc}{cunifvariate}{mean\, arc}
29+
Circular uniform distribution. \var{mean} is the mean angle, and
30+
\var{arc} is the range of the distribution, centered around the mean
31+
angle. Both values must be expressed in radians, and can range
32+
between 0 and \code{pi}. Returned values will range between
33+
\code{mean - arc/2} and \code{mean + arc/2}.
34+
\end{funcdesc}
35+
36+
\begin{funcdesc}{expovariate}{lambd}
37+
Exponential distribution. \var{lambd} is 1.0 divided by the desired mean.
38+
(The parameter would be called ``lambda'', but that's also a reserved
39+
word in Python.) Returned values will range from 0 to positive infinity.
40+
\end{funcdesc}
41+
42+
\begin{funcdesc}{gamma}{alpha\, beta}
43+
Gamma distribution. (\emph{Not} the gamma function!)
44+
Conditions on the parameters are \code{alpha>-1} and \code{beta>0}.
45+
\end{funcdesc}
46+
47+
\begin{funcdesc}{gauss}{mu\, sigma}
48+
Gaussian distribution. \var{mu} is the mean, and \var{sigma} is the
49+
standard deviation. This is slightly faster than the
50+
\code{normalvariate} function defined below.
51+
\end{funcdesc}
52+
53+
\begin{funcdesc}{lognormvariate}{mu\, sigma}
54+
Log normal distribution. If you take the natural logarithm of this
55+
distribution, you'll get a normal distribution with mean \var{mu} and
56+
standard deviation \var{sigma} \var{mu} can have any value, and \var{sigma}
57+
must be greater than zero.
58+
\end{funcdesc}
59+
60+
\begin{funcdesc}{normalvariate}{mu\, sigma}
61+
Normal distribution. \var{mu} is the mean, and \var{sigma} is the
62+
standard deviation.
63+
\end{funcdesc}
64+
65+
\begin{funcdesc}{vonmisesvariate}{mu\, kappa}
66+
\var{mu} is the mean angle, expressed in radians between 0 and pi,
67+
and \var{kappa} is the concentration parameter, which must be greater
68+
then or equal to zero. If \var{kappa} is equal to zero, this
69+
distribution reduces to a uniform random angle over the range 0 to
70+
\code{2*pi}.
71+
\end{funcdesc}

Doc/lib/libsite.tex

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
\section{Standard Module \sectcode{site}}
2+
\stmodindex{site}
3+
4+
Scripts or modules that need to use site-specific modules should
5+
execute \code{import site} somewhere near the top of their code. This
6+
will append up to two site-specific paths (\code{sys.prefix +
7+
'/lib/site-python'} and
8+
\code{sys.exec_prefix + '/lib/site-python'}) to the module search path.
9+
\code{sys.prefix} and \code{sys.exec_prefix} are configured when Python is installed; the default value is \file{/usr/local}.
10+
11+
Because of Python's import semantics, it is okay for more than one
12+
module to import \code{site} -- only the first one will execute the
13+
site customizations. The directories are only appended to the path if
14+
they exist and are not already on it.
15+
16+
Sites that wish to provide site-specific modules should place them in
17+
one of the site specific directories; \code{sys.prefix +
18+
'/lib/site-python'} is for Python source code and
19+
\code{sys.exec_prefix + '/lib/site-python'} is for dynamically
20+
loadable extension modules (shared libraries).
21+
22+
After these path manipulations, an attempt is made to import a module
23+
named \code{sitecustomize}, which can perform arbitrary site-specific
24+
customizations. If this import fails with an \code{ImportError}
25+
exception, it is ignored.
26+
27+
Note that for non-Unix systems, \code{sys.prefix} and
28+
\code{sys.exec_prefix} are empty, and the path manipulations are
29+
skipped; however the import of \code{sitecustomize} is still attempted.

Doc/lib/libsomeos.tex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ \chapter{Optional Operating System Services}
2020
\item[thread]
2121
--- Create multiple threads of control within one namespace.
2222

23+
\item[anydbm]
24+
--- Generic interface to DBM-style database modules.
25+
\item[whichdbm]
26+
--- Guess which DBM-style module created a given database.
27+
2328
\end{description}

Doc/lib/libwhichdb.tex

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
\section{Standard Module \sectcode{whichdb}}
2+
\stmodindex{whichdb}
3+
4+
The single function in this module attempts to guess which of the
5+
several simple database modules available--dbm, gdbm, or
6+
dbhash--should be used to open a given file.
7+
8+
\renewcommand{\indexsubitem}{(in module whichdb)}
9+
\begin{funcdesc}{whichdb}{filename}
10+
Returns one of the following values: \code{None} if the file can't be
11+
opened because it's unreadable or doesn't exist; the empty string
12+
(\code{""}) if the file's format can't be guessed; or a string
13+
containing the required module name, such as \code{"dbm"} or
14+
\code{"gdbm"}.
15+
\end{funcdesc}
16+

0 commit comments

Comments
 (0)