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
246249A 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')
2632661
264267>>>
265- \end {verbatim }\end { code }
268+ \end {verbatim }\ecode
266269\subsubsection {Other Built-in Types }
267270
268271The interpreter supports several other kinds of objects.
@@ -405,30 +408,30 @@ \subsection{Built-in Functions}
405408With a module object as argument, it returns the sorted list of names in
406409that module's global symbol table.
407410For 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
418421Takes two integers as arguments and returns a pair of integers
419422consisting of their quotient and remainder.
420423For
421- \begin { code } \begin {verbatim }
424+ \bcode \begin {verbatim }
422425q, r = divmod(a, b)
423- \end {verbatim }\end { code }
426+ \end {verbatim }\ecode
424427the invariants are:
425- \begin { code } \begin {verbatim }
428+ \bcode \begin {verbatim }
426429a = q*b + r
427430abs(r) < abs(b)
428431r has the same sign as b
429- \end {verbatim }\end { code }
432+ \end {verbatim }\ecode
430433For 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)}]
443446Takes a string as argument and parses and evaluates it as a {\Python }
444447expression.
445448The expression is executed using the current local and global symbol
446449tables.
447450Syntax errors are reported as exceptions.
448451For example:
449- \begin { code } \begin {verbatim }
452+ \bcode \begin {verbatim }
450453>>> x = 1
451454>>> eval('x+1')
4524552
453456>>>
454- \end {verbatim }\end { code }
457+ \end {verbatim }\ecode
455458\item [{\tt exec(s)}]
456459Takes a string as argument and parses and evaluates it as a sequence of
457460{\Python } statements.
@@ -460,13 +463,13 @@ \subsection{Built-in Functions}
460463tables.
461464Syntax errors are reported as exceptions.
462465For example:
463- \begin { code } \begin {verbatim }
466+ \bcode \begin {verbatim }
464467>>> x = 1
465468>>> exec('x = x+1\n')
466469>>> x
4674702
468471>>>
469- \end {verbatim }\end { code }
472+ \end {verbatim }\ecode
470473\item [{\tt float(x)}]
471474Converts a number to floating point.
472475The argument may be an integer or floating point number.
@@ -511,7 +514,7 @@ \subsection{Built-in Functions}
511514work as expected, but don't specify a zero step.
512515The resulting list may be empty.
513516For 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
533536The 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.
537540EOF is reported as an exception.
538541For example:
539- \begin { code } \begin {verbatim }
542+ \bcode \begin {verbatim }
540543>>> raw_input('Type anything: ')
541544Type 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)}]
546549Returns the type of an object.
547550Types are objects themselves:
@@ -954,9 +957,10 @@ \subsubsection{Functions Defined in Module {\tt stdwin}}
954957\item [{\tt textwidth(str)}]
955958% .br
956959Return 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+
960964Window objects are created by
961965{\tt stdwin.open()}.
962966There is no explicit function to close a window; windows are closed when
@@ -971,8 +975,10 @@ \subsubsection{Window Object Methods}
971975\item [{\tt gettitle()}]
972976Returns the window's title string.
973977\item [{\tt getdocsize()}]
978+ \begin {sloppypar }
974979Returns a pair of integers giving the size of the document as set by
975980{\tt setdocsize()}.
981+ \end {sloppypar }
976982\item [{\tt getorigin()}]
977983Returns a pair of integers giving the origin of the window with respect
978984to the document.
@@ -985,6 +991,7 @@ \subsubsection{Window Object Methods}
985991\item [{\tt scroll(rect,~point)}]
986992Scrolls the given rectangle by the vector given by the point.
987993\item [{\tt setwincursor(name)}]
994+ \begin {sloppypar }
988995Sets the window cursor to a cursor of the given name.
989996It raises the
990997{\tt Runtime\- Error}
@@ -998,6 +1005,7 @@ \subsubsection{Window Object Methods}
9981005{\tt 'plus' }.
9991006On X11, there are many more (see
10001007{\tt <X11/cursorfont.h>}).
1008+ \end {sloppypar }
10011009\item [{\tt setdocsize(point)}]
10021010Sets the size of the drawing document.
10031011\item [{\tt setorigin(point)}]
@@ -1233,11 +1241,11 @@ \subsubsection{Capability Operations}
12331241and
12341242{\em a2c}(U).
12351243For example:
1236- \begin { code } \begin {verbatim }
1244+ \bcode \begin {verbatim }
12371245>>> amoeba.name_lookup('/profile/cap')
12381246aa:1c:95:52:6a:fa/14(ff)/8e:ba:5b:8:11:1a
12391247>>>
1240- \end {verbatim }\end { code }
1248+ \end {verbatim }\ecode
12411249The following methods are defined for capability objects.
12421250\begin {description }
12431251\item [{\tt dir\_ list()}]
@@ -1254,6 +1262,7 @@ \subsubsection{Capability Operations}
12541262Returns the size of a bullet file.
12551263\item [{\tt dir\_ append(), dir\_ delete(), dir\_ lookup(), dir\_ replace()}]
12561264% .br
1265+ \itembreak
12571266Like the corresponding
12581267{\tt name\_ *}
12591268functions, 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 }
13211331Similar but for output.
13221332{\tt stop\_ playing()}
13231333returns a lower bound for the number of bytes actually played (not very
13241334accurate).
1335+ \end {sloppypar }
13251336\end {description }
13261337
13271338The following operations do not affect the audio device but are
@@ -1347,10 +1358,12 @@ \subsection{Built-in Module {\tt audio}}
13471358a list containing the numeric values of the samples.
13481359\item [{\tt num2chr(list)}]
13491360% .br
1361+ \begin {sloppypar }
13501362Converts a list as returned by
13511363{\tt chr2num()}
13521364back 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}}
13821395All arrays are represented by one-dimensional {\Python } lists.
13831396In most cases, tuples are also allowed.
13841397\item
1398+ \begin {sloppypar }
13851399All string and character arguments are represented by {\Python } strings,
1386- e.g. ,
1400+ for instance ,
13871401{\tt winopen('Hi~There!')}
13881402and
13891403{\tt rotate(900,~'z')}.
1404+ \end {sloppypar }
13901405\item
13911406All (short, long, unsigned) integer arguments or return values that are
13921407only used to specify the length of an array argument are omitted.
13931408For example, the C call
1394- \begin { code } \begin {verbatim }
1409+ \bcode \begin {verbatim }
13951410lmdef(deftype, index, np, props)
1396- \end {verbatim }\end { code }
1411+ \end {verbatim }\ecode
13971412is translated to {\Python } as
1398- \begin { code } \begin {verbatim }
1413+ \bcode \begin {verbatim }
13991414lmdef(deftype, index, props)
1400- \end {verbatim }\end { code }
1415+ \end {verbatim }\ecode
14011416\item
14021417Output arguments are omitted from the argument list; they are
14031418transmitted as function return values instead.
@@ -1406,13 +1421,13 @@ \subsection{Built-in Module {\tt gl}}
14061421because of the previous rule) and an output argument, the return value
14071422comes first in the tuple.
14081423Examples: the C call
1409- \begin { code } \begin {verbatim }
1424+ \bcode \begin {verbatim }
14101425getmcolor(i, &red, &green, &blue)
1411- \end {verbatim }\end { code }
1426+ \end {verbatim }\ecode
14121427is translated to {\Python } as
1413- \begin { code } \begin {verbatim }
1428+ \bcode \begin {verbatim }
14141429red, green, blue = getmcolor(i)
1415- \end {verbatim }\end { code }
1430+ \end {verbatim }\ecode
14161431\end {itemize }
14171432
14181433The following functions are non-standard or have special argument
@@ -1454,6 +1469,7 @@ \subsection{Built-in Module {\tt gl}}
14541469but 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
14571473Defines a nurbs surface.
14581474The dimensions of
14591475{\tt ctl[][]}
@@ -1486,7 +1502,7 @@ \subsection{Built-in Module {\tt gl}}
14861502\end {description }
14871503
14881504Here is a tiny but complete example GL program in {\Python }:
1489- \begin { code } \begin {verbatim }
1505+ \bcode \begin {verbatim }
14901506import gl, GL, time
14911507
14921508def main():
@@ -1508,15 +1524,14 @@ \subsection{Built-in Module {\tt gl}}
15081524 time.sleep(5)
15091525
15101526main()
1511- \end {verbatim }\end { code }
1527+ \end {verbatim }\ecode
15121528
15131529\subsection {Built-in Module {\tt pnl} }
15141530
15151531This 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+ 15201535All access to it should be done through the standard module
15211536{\tt panel},
15221537which transparantly exports most functions from
@@ -1775,7 +1790,7 @@ \subsection{Standard Module {\tt getopt}}
17751790The options occur in the list in the same order in which they were
17761791found, thus allowing multiple occurrences.
17771792Example:
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
17901805The exception
17911806{\tt getopt.error = 'getopt error' }
17921807is raised when an unrecognized option is found in the argument list or
@@ -1836,10 +1851,10 @@ \subsection{Standard Module {\tt stdwinevents}}
18361851and selection types ({\tt WS\_ PRIMARY} etc.).
18371852Read the file for details.
18381853Suggested 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}:
18491864a pair of points, where a point is a pair of integers.
18501865For 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
18541869is a rectangle whose left, top, right and bottom edges are 10, 20, 90
18551870and 80, respectively.
18561871Note that the positive vertical axis points down (as in
@@ -1868,15 +1883,15 @@ \subsection{Standard Module {\tt rect}}
18681883% .br
18691884The rectangle returned when some operations return an empty result.
18701885This 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'
18771892Empty intersection
18781893>>>
1879- \end {verbatim }\end { code }
1894+ \end {verbatim }\ecode
18801895\item [{\tt is\_ empty(r)}]
18811896% .br
18821897Returns true if the given rectangle is empty.
0 commit comments