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

Skip to content

Commit d38b764

Browse files
committed
Changed \begin{code} and \end{code} into \bcode and \ecode.
Small lay-out improvements.
1 parent 44000ed commit d38b764

2 files changed

Lines changed: 122 additions & 92 deletions

File tree

Doc/lib.tex

Lines changed: 61 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
% Format this file with latex.
22

3-
\documentstyle[palatino,11pt,myformat]{article}
4-
%\documentstyle[11pt,myformat]{article}
3+
%\documentstyle[palatino,11pt,myformat]{article}
4+
\documentstyle[11pt,myformat]{article}
55

6-
\sloppy
6+
% A command to force the text after an item to start on a new line
7+
\newcommand{\itembreak}{
8+
\mbox{}\\*[0mm]
9+
}
710

811
\title{\bf
912
Python Library Reference \\
@@ -244,7 +247,7 @@ \subsubsection{Mapping Types}
244247
\end{description}
245248

246249
A small example using a dictionary:
247-
\begin{code}\begin{verbatim}
250+
\bcode\begin{verbatim}
248251
>>> tel = {}
249252
>>> tel['jack'] = 4098
250253
>>> tel['sape'] = 4139
@@ -262,7 +265,7 @@ \subsubsection{Mapping Types}
262265
>>> tel.has_key('guido')
263266
1
264267
>>>
265-
\end{verbatim}\end{code}
268+
\end{verbatim}\ecode
266269
\subsubsection{Other Built-in Types}
267270

268271
The interpreter supports several other kinds of objects.
@@ -405,30 +408,30 @@ \subsection{Built-in Functions}
405408
With a module object as argument, it returns the sorted list of names in
406409
that module's global symbol table.
407410
For example:
408-
\begin{code}\begin{verbatim}
411+
\bcode\begin{verbatim}
409412
>>> import sys
410413
>>> dir()
411414
['sys']
412415
>>> dir(sys)
413416
['argv', 'exit', 'modules', 'path', 'stderr', 'stdin', 'stdout']
414417
>>>
415-
\end{verbatim}\end{code}
418+
\end{verbatim}\ecode
416419
\item[{\tt divmod(a, b)}]
417420
%.br
418421
Takes two integers as arguments and returns a pair of integers
419422
consisting of their quotient and remainder.
420423
For
421-
\begin{code}\begin{verbatim}
424+
\bcode\begin{verbatim}
422425
q, r = divmod(a, b)
423-
\end{verbatim}\end{code}
426+
\end{verbatim}\ecode
424427
the invariants are:
425-
\begin{code}\begin{verbatim}
428+
\bcode\begin{verbatim}
426429
a = q*b + r
427430
abs(r) < abs(b)
428431
r has the same sign as b
429-
\end{verbatim}\end{code}
432+
\end{verbatim}\ecode
430433
For example:
431-
\begin{code}\begin{verbatim}
434+
\bcode\begin{verbatim}
432435
>>> divmod(100, 7)
433436
(14, 2)
434437
>>> divmod(-100, 7)
@@ -438,20 +441,20 @@ \subsection{Built-in Functions}
438441
>>> divmod(-100, -7)
439442
(14, -2)
440443
>>>
441-
\end{verbatim}\end{code}
444+
\end{verbatim}\ecode
442445
\item[{\tt eval(s)}]
443446
Takes a string as argument and parses and evaluates it as a {\Python}
444447
expression.
445448
The expression is executed using the current local and global symbol
446449
tables.
447450
Syntax errors are reported as exceptions.
448451
For example:
449-
\begin{code}\begin{verbatim}
452+
\bcode\begin{verbatim}
450453
>>> x = 1
451454
>>> eval('x+1')
452455
2
453456
>>>
454-
\end{verbatim}\end{code}
457+
\end{verbatim}\ecode
455458
\item[{\tt exec(s)}]
456459
Takes a string as argument and parses and evaluates it as a sequence of
457460
{\Python} statements.
@@ -460,13 +463,13 @@ \subsection{Built-in Functions}
460463
tables.
461464
Syntax errors are reported as exceptions.
462465
For example:
463-
\begin{code}\begin{verbatim}
466+
\bcode\begin{verbatim}
464467
>>> x = 1
465468
>>> exec('x = x+1\n')
466469
>>> x
467470
2
468471
>>>
469-
\end{verbatim}\end{code}
472+
\end{verbatim}\ecode
470473
\item[{\tt float(x)}]
471474
Converts a number to floating point.
472475
The argument may be an integer or floating point number.
@@ -511,7 +514,7 @@ \subsection{Built-in Functions}
511514
work as expected, but don't specify a zero step.
512515
The resulting list may be empty.
513516
For example:
514-
\begin{code}\begin{verbatim}
517+
\bcode\begin{verbatim}
515518
>>> range(10)
516519
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
517520
>>> range(1, 1+10)
@@ -527,7 +530,7 @@ \subsection{Built-in Functions}
527530
>>> range(1, 0)
528531
[]
529532
>>>
530-
\end{verbatim}\end{code}
533+
\end{verbatim}\ecode
531534
\item[{\tt raw\_input(s)}]
532535
%.br
533536
The argument is optional; if present, it is written to standard output
@@ -536,12 +539,12 @@ \subsection{Built-in Functions}
536539
(stripping a trailing newline), and returns that.
537540
EOF is reported as an exception.
538541
For example:
539-
\begin{code}\begin{verbatim}
542+
\bcode\begin{verbatim}
540543
>>> raw_input('Type anything: ')
541544
Type anything: Teenage Mutant Ninja Turtles
542545
'Teenage Mutant Ninja Turtles'
543546
>>>
544-
\end{verbatim}\end{code}
547+
\end{verbatim}\ecode
545548
\item[{\tt type(x)}]
546549
Returns the type of an object.
547550
Types are objects themselves:
@@ -954,9 +957,10 @@ \subsubsection{Functions Defined in Module {\tt stdwin}}
954957
\item[{\tt textwidth(str)}]
955958
%.br
956959
Return the width in bits of the string when drawn in the current font.
957-
\subsubsection{Window Object Methods}
958960
\end{description}
959961

962+
\subsubsection{Window Object Methods}
963+
960964
Window objects are created by
961965
{\tt stdwin.open()}.
962966
There is no explicit function to close a window; windows are closed when
@@ -971,8 +975,10 @@ \subsubsection{Window Object Methods}
971975
\item[{\tt gettitle()}]
972976
Returns the window's title string.
973977
\item[{\tt getdocsize()}]
978+
\begin{sloppypar}
974979
Returns a pair of integers giving the size of the document as set by
975980
{\tt setdocsize()}.
981+
\end{sloppypar}
976982
\item[{\tt getorigin()}]
977983
Returns a pair of integers giving the origin of the window with respect
978984
to the document.
@@ -985,6 +991,7 @@ \subsubsection{Window Object Methods}
985991
\item[{\tt scroll(rect,~point)}]
986992
Scrolls the given rectangle by the vector given by the point.
987993
\item[{\tt setwincursor(name)}]
994+
\begin{sloppypar}
988995
Sets the window cursor to a cursor of the given name.
989996
It raises the
990997
{\tt Runtime\-Error}
@@ -998,6 +1005,7 @@ \subsubsection{Window Object Methods}
9981005
{\tt 'plus'}.
9991006
On X11, there are many more (see
10001007
{\tt <X11/cursorfont.h>}).
1008+
\end{sloppypar}
10011009
\item[{\tt setdocsize(point)}]
10021010
Sets the size of the drawing document.
10031011
\item[{\tt setorigin(point)}]
@@ -1233,11 +1241,11 @@ \subsubsection{Capability Operations}
12331241
and
12341242
{\em a2c}(U).
12351243
For example:
1236-
\begin{code}\begin{verbatim}
1244+
\bcode\begin{verbatim}
12371245
>>> amoeba.name_lookup('/profile/cap')
12381246
aa:1c:95:52:6a:fa/14(ff)/8e:ba:5b:8:11:1a
12391247
>>>
1240-
\end{verbatim}\end{code}
1248+
\end{verbatim}\ecode
12411249
The following methods are defined for capability objects.
12421250
\begin{description}
12431251
\item[{\tt dir\_list()}]
@@ -1254,6 +1262,7 @@ \subsubsection{Capability Operations}
12541262
Returns the size of a bullet file.
12551263
\item[{\tt dir\_append(), dir\_delete(), dir\_lookup(), dir\_replace()}]
12561264
%.br
1265+
\itembreak
12571266
Like the corresponding
12581267
{\tt name\_*}
12591268
functions, but with a path relative to the capability.
@@ -1318,10 +1327,12 @@ \subsection{Built-in Module {\tt audio}}
13181327
\item[{\tt start\_playing(chunk)}, {\tt wait\_playing()},
13191328
{\tt stop\_playing()}, {\tt poll\_playing()}]
13201329
%.br
1330+
\begin{sloppypar}
13211331
Similar but for output.
13221332
{\tt stop\_playing()}
13231333
returns a lower bound for the number of bytes actually played (not very
13241334
accurate).
1335+
\end{sloppypar}
13251336
\end{description}
13261337

13271338
The following operations do not affect the audio device but are
@@ -1347,10 +1358,12 @@ \subsection{Built-in Module {\tt audio}}
13471358
a list containing the numeric values of the samples.
13481359
\item[{\tt num2chr(list)}]
13491360
%.br
1361+
\begin{sloppypar}
13501362
Converts a list as returned by
13511363
{\tt chr2num()}
13521364
back to a buffer acceptable by
13531365
{\tt write()}.
1366+
\end{sloppypar}
13541367
\end{description}
13551368

13561369
\subsection{Built-in Module {\tt gl}}
@@ -1382,22 +1395,24 @@ \subsection{Built-in Module {\tt gl}}
13821395
All arrays are represented by one-dimensional {\Python} lists.
13831396
In most cases, tuples are also allowed.
13841397
\item
1398+
\begin{sloppypar}
13851399
All string and character arguments are represented by {\Python} strings,
1386-
e.g.,
1400+
for instance,
13871401
{\tt winopen('Hi~There!')}
13881402
and
13891403
{\tt rotate(900,~'z')}.
1404+
\end{sloppypar}
13901405
\item
13911406
All (short, long, unsigned) integer arguments or return values that are
13921407
only used to specify the length of an array argument are omitted.
13931408
For example, the C call
1394-
\begin{code}\begin{verbatim}
1409+
\bcode\begin{verbatim}
13951410
lmdef(deftype, index, np, props)
1396-
\end{verbatim}\end{code}
1411+
\end{verbatim}\ecode
13971412
is translated to {\Python} as
1398-
\begin{code}\begin{verbatim}
1413+
\bcode\begin{verbatim}
13991414
lmdef(deftype, index, props)
1400-
\end{verbatim}\end{code}
1415+
\end{verbatim}\ecode
14011416
\item
14021417
Output arguments are omitted from the argument list; they are
14031418
transmitted as function return values instead.
@@ -1406,13 +1421,13 @@ \subsection{Built-in Module {\tt gl}}
14061421
because of the previous rule) and an output argument, the return value
14071422
comes first in the tuple.
14081423
Examples: the C call
1409-
\begin{code}\begin{verbatim}
1424+
\bcode\begin{verbatim}
14101425
getmcolor(i, &red, &green, &blue)
1411-
\end{verbatim}\end{code}
1426+
\end{verbatim}\ecode
14121427
is translated to {\Python} as
1413-
\begin{code}\begin{verbatim}
1428+
\bcode\begin{verbatim}
14141429
red, green, blue = getmcolor(i)
1415-
\end{verbatim}\end{code}
1430+
\end{verbatim}\ecode
14161431
\end{itemize}
14171432

14181433
The following functions are non-standard or have special argument
@@ -1454,6 +1469,7 @@ \subsection{Built-in Module {\tt gl}}
14541469
but the pairs have the point first and the normal second.
14551470
\item[{\tt nurbssurface(s\_k[], t\_k[], ctl[][], s\_ord, t\_ord, type)}]
14561471
%.br
1472+
\itembreak
14571473
Defines a nurbs surface.
14581474
The dimensions of
14591475
{\tt ctl[][]}
@@ -1486,7 +1502,7 @@ \subsection{Built-in Module {\tt gl}}
14861502
\end{description}
14871503

14881504
Here is a tiny but complete example GL program in {\Python}:
1489-
\begin{code}\begin{verbatim}
1505+
\bcode\begin{verbatim}
14901506
import gl, GL, time
14911507
14921508
def main():
@@ -1508,15 +1524,14 @@ \subsection{Built-in Module {\tt gl}}
15081524
time.sleep(5)
15091525
15101526
main()
1511-
\end{verbatim}\end{code}
1527+
\end{verbatim}\ecode
15121528

15131529
\subsection{Built-in Module {\tt pnl}}
15141530

15151531
This module provides access to the
15161532
{\em Panel Library}
1517-
built by NASA Ames (write to
1518-
1519-
to get it).
1533+
built by NASA Ames (to get it, send e-mail to
1534+
15201535
All access to it should be done through the standard module
15211536
{\tt panel},
15221537
which transparantly exports most functions from
@@ -1775,7 +1790,7 @@ \subsection{Standard Module {\tt getopt}}
17751790
The options occur in the list in the same order in which they were
17761791
found, thus allowing multiple occurrences.
17771792
Example:
1778-
\begin{code}\begin{verbatim}
1793+
\bcode\begin{verbatim}
17791794
>>> import getopt, string
17801795
>>> args = string.split('-a -b -cfoo -d bar a1 a2')
17811796
>>> args
@@ -1786,7 +1801,7 @@ \subsection{Standard Module {\tt getopt}}
17861801
>>> args
17871802
['a1', 'a2']
17881803
>>>
1789-
\end{verbatim}\end{code}
1804+
\end{verbatim}\ecode
17901805
The exception
17911806
{\tt getopt.error = 'getopt error'}
17921807
is raised when an unrecognized option is found in the argument list or
@@ -1836,10 +1851,10 @@ \subsection{Standard Module {\tt stdwinevents}}
18361851
and selection types ({\tt WS\_PRIMARY} etc.).
18371852
Read the file for details.
18381853
Suggested usage is
1839-
\begin{code}\begin{verbatim}
1854+
\bcode\begin{verbatim}
18401855
>>> from stdwinevents import *
18411856
>>>
1842-
\end{verbatim}\end{code}
1857+
\end{verbatim}\ecode
18431858

18441859
\subsection{Standard Module {\tt rect}}
18451860

@@ -1848,9 +1863,9 @@ \subsection{Standard Module {\tt rect}}
18481863
{\tt stdwin}:
18491864
a pair of points, where a point is a pair of integers.
18501865
For example, the rectangle
1851-
\begin{code}\begin{verbatim}
1866+
\bcode\begin{verbatim}
18521867
(10, 20), (90, 80)
1853-
\end{verbatim}\end{code}
1868+
\end{verbatim}\ecode
18541869
is a rectangle whose left, top, right and bottom edges are 10, 20, 90
18551870
and 80, respectively.
18561871
Note that the positive vertical axis points down (as in
@@ -1868,15 +1883,15 @@ \subsection{Standard Module {\tt rect}}
18681883
%.br
18691884
The rectangle returned when some operations return an empty result.
18701885
This makes it possible to quickly check whether a result is empty:
1871-
\begin{code}\begin{verbatim}
1886+
\bcode\begin{verbatim}
18721887
>>> import rect
18731888
>>> r1 = (10, 20), (90, 80)
18741889
>>> r2 = (0, 0), (10, 20)
18751890
>>> r3 = rect.intersect(r1, r2)
18761891
>>> if r3 is rect.empty: print 'Empty intersection'
18771892
Empty intersection
18781893
>>>
1879-
\end{verbatim}\end{code}
1894+
\end{verbatim}\ecode
18801895
\item[{\tt is\_empty(r)}]
18811896
%.br
18821897
Returns true if the given rectangle is empty.

0 commit comments

Comments
 (0)