home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: LaTeX Document
(document/latex).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| LaTeX Document (document/latex)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| LaTeX document text
| default
| |
99%
| file
| LaTeX document, ASCII text
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/281 LaTeX (Subdocument)
| default
| |
100%
| detectItEasy
| Format: plain text[LF]
| default (weak)
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 42 75 69 6c 74 2d 69 |\section|{Built-i|
|00000010| 6e 20 46 75 6e 63 74 69 | 6f 6e 73 7d 0a 0a 54 68 |n Functi|ons}..Th|
|00000020| 65 20 50 79 74 68 6f 6e | 20 69 6e 74 65 72 70 72 |e Python| interpr|
|00000030| 65 74 65 72 20 68 61 73 | 20 61 20 6e 75 6d 62 65 |eter has| a numbe|
|00000040| 72 20 6f 66 20 66 75 6e | 63 74 69 6f 6e 73 20 62 |r of fun|ctions b|
|00000050| 75 69 6c 74 20 69 6e 74 | 6f 20 69 74 20 74 68 61 |uilt int|o it tha|
|00000060| 74 0a 61 72 65 20 61 6c | 77 61 79 73 20 61 76 61 |t.are al|ways ava|
|00000070| 69 6c 61 62 6c 65 2e 20 | 20 54 68 65 79 20 61 72 |ilable. | They ar|
|00000080| 65 20 6c 69 73 74 65 64 | 20 68 65 72 65 20 69 6e |e listed| here in|
|00000090| 20 61 6c 70 68 61 62 65 | 74 69 63 61 6c 20 6f 72 | alphabe|tical or|
|000000a0| 64 65 72 2e 0a 0a 0a 5c | 72 65 6e 65 77 63 6f 6d |der....\|renewcom|
|000000b0| 6d 61 6e 64 7b 5c 69 6e | 64 65 78 73 75 62 69 74 |mand{\in|dexsubit|
|000000c0| 65 6d 7d 7b 28 62 75 69 | 6c 74 2d 69 6e 20 66 75 |em}{(bui|lt-in fu|
|000000d0| 6e 63 74 69 6f 6e 29 7d | 0a 5c 62 65 67 69 6e 7b |nction)}|.\begin{|
|000000e0| 66 75 6e 63 64 65 73 63 | 7d 7b 61 62 73 7d 7b 78 |funcdesc|}{abs}{x|
|000000f0| 7d 0a 20 20 52 65 74 75 | 72 6e 20 74 68 65 20 61 |}. Retu|rn the a|
|00000100| 62 73 6f 6c 75 74 65 20 | 76 61 6c 75 65 20 6f 66 |bsolute |value of|
|00000110| 20 61 20 6e 75 6d 62 65 | 72 2e 20 20 54 68 65 20 | a numbe|r. The |
|00000120| 61 72 67 75 6d 65 6e 74 | 20 6d 61 79 20 62 65 20 |argument| may be |
|00000130| 61 20 70 6c 61 69 6e 0a | 20 20 6f 72 20 6c 6f 6e |a plain.| or lon|
|00000140| 67 20 69 6e 74 65 67 65 | 72 20 6f 72 20 61 20 66 |g intege|r or a f|
|00000150| 6c 6f 61 74 69 6e 67 20 | 70 6f 69 6e 74 20 6e 75 |loating |point nu|
|00000160| 6d 62 65 72 2e 0a 5c 65 | 6e 64 7b 66 75 6e 63 64 |mber..\e|nd{funcd|
|00000170| 65 73 63 7d 0a 0a 5c 62 | 65 67 69 6e 7b 66 75 6e |esc}..\b|egin{fun|
|00000180| 63 64 65 73 63 7d 7b 61 | 70 70 6c 79 7d 7b 66 75 |cdesc}{a|pply}{fu|
|00000190| 6e 63 74 69 6f 6e 5c 2c | 20 61 72 67 73 5c 6f 70 |nction\,| args\op|
|000001a0| 74 69 6f 6e 61 6c 7b 2c | 20 6b 65 79 77 6f 72 64 |tional{,| keyword|
|000001b0| 73 7d 7d 0a 54 68 65 20 | 5c 76 61 72 7b 66 75 6e |s}}.The |\var{fun|
|000001c0| 63 74 69 6f 6e 7d 20 61 | 72 67 75 6d 65 6e 74 20 |ction} a|rgument |
|000001d0| 6d 75 73 74 20 62 65 20 | 61 20 63 61 6c 6c 61 62 |must be |a callab|
|000001e0| 6c 65 20 6f 62 6a 65 63 | 74 20 28 61 20 75 73 65 |le objec|t (a use|
|000001f0| 72 2d 64 65 66 69 6e 65 | 64 20 6f 72 0a 62 75 69 |r-define|d or.bui|
|00000200| 6c 74 2d 69 6e 20 66 75 | 6e 63 74 69 6f 6e 20 6f |lt-in fu|nction o|
|00000210| 72 20 6d 65 74 68 6f 64 | 2c 20 6f 72 20 61 20 63 |r method|, or a c|
|00000220| 6c 61 73 73 20 6f 62 6a | 65 63 74 29 20 61 6e 64 |lass obj|ect) and|
|00000230| 20 74 68 65 20 5c 76 61 | 72 7b 61 72 67 73 7d 0a | the \va|r{args}.|
|00000240| 61 72 67 75 6d 65 6e 74 | 20 6d 75 73 74 20 62 65 |argument| must be|
|00000250| 20 61 20 74 75 70 6c 65 | 2e 20 20 54 68 65 20 5c | a tuple|. The \|
|00000260| 76 61 72 7b 66 75 6e 63 | 74 69 6f 6e 7d 20 69 73 |var{func|tion} is|
|00000270| 20 63 61 6c 6c 65 64 20 | 77 69 74 68 0a 5c 76 61 | called |with.\va|
|00000280| 72 7b 61 72 67 73 7d 20 | 61 73 20 61 72 67 75 6d |r{args} |as argum|
|00000290| 65 6e 74 20 6c 69 73 74 | 3b 20 74 68 65 20 6e 75 |ent list|; the nu|
|000002a0| 6d 62 65 72 20 6f 66 20 | 61 72 67 75 6d 65 6e 74 |mber of |argument|
|000002b0| 73 20 69 73 20 74 68 65 | 20 74 68 65 20 6c 65 6e |s is the| the len|
|000002c0| 67 74 68 0a 6f 66 20 74 | 68 65 20 74 75 70 6c 65 |gth.of t|he tuple|
|000002d0| 2e 20 20 28 54 68 69 73 | 20 69 73 20 64 69 66 66 |. (This| is diff|
|000002e0| 65 72 65 6e 74 20 66 72 | 6f 6d 20 6a 75 73 74 20 |erent fr|om just |
|000002f0| 63 61 6c 6c 69 6e 67 0a | 5c 63 6f 64 65 7b 5c 76 |calling.|\code{\v|
|00000300| 61 72 7b 66 75 6e 63 7d | 28 5c 76 61 72 7b 61 72 |ar{func}|(\var{ar|
|00000310| 67 73 7d 29 7d 2c 20 73 | 69 6e 63 65 20 69 6e 20 |gs})}, s|ince in |
|00000320| 74 68 61 74 20 63 61 73 | 65 20 74 68 65 72 65 20 |that cas|e there |
|00000330| 69 73 20 61 6c 77 61 79 | 73 0a 65 78 61 63 74 6c |is alway|s.exactl|
|00000340| 79 20 6f 6e 65 20 61 72 | 67 75 6d 65 6e 74 2e 29 |y one ar|gument.)|
|00000350| 0a 49 66 20 74 68 65 20 | 6f 70 74 69 6f 6e 61 6c |.If the |optional|
|00000360| 20 5c 76 61 72 7b 6b 65 | 79 77 6f 72 64 73 7d 20 | \var{ke|ywords} |
|00000370| 61 72 67 75 6d 65 6e 74 | 20 69 73 20 70 72 65 73 |argument| is pres|
|00000380| 65 6e 74 2c 20 69 74 20 | 6d 75 73 74 20 62 65 20 |ent, it |must be |
|00000390| 61 0a 64 69 63 74 69 6f | 6e 61 72 79 20 77 68 6f |a.dictio|nary who|
|000003a0| 73 65 20 6b 65 79 73 20 | 61 72 65 20 73 74 72 69 |se keys |are stri|
|000003b0| 6e 67 73 2e 20 20 49 74 | 20 73 70 65 63 69 66 69 |ngs. It| specifi|
|000003c0| 65 73 20 6b 65 79 77 6f | 72 64 20 61 72 67 75 6d |es keywo|rd argum|
|000003d0| 65 6e 74 73 20 74 6f 0a | 62 65 20 61 64 64 65 64 |ents to.|be added|
|000003e0| 20 74 6f 20 74 68 65 20 | 65 6e 64 20 6f 66 20 74 | to the |end of t|
|000003f0| 68 65 20 74 68 65 20 61 | 72 67 75 6d 65 6e 74 20 |he the a|rgument |
|00000400| 6c 69 73 74 2e 0a 5c 65 | 6e 64 7b 66 75 6e 63 64 |list..\e|nd{funcd|
|00000410| 65 73 63 7d 0a 0a 5c 62 | 65 67 69 6e 7b 66 75 6e |esc}..\b|egin{fun|
|00000420| 63 64 65 73 63 7d 7b 63 | 68 72 7d 7b 69 7d 0a 20 |cdesc}{c|hr}{i}. |
|00000430| 20 52 65 74 75 72 6e 20 | 61 20 73 74 72 69 6e 67 | Return |a string|
|00000440| 20 6f 66 20 6f 6e 65 20 | 63 68 61 72 61 63 74 65 | of one |characte|
|00000450| 72 20 77 68 6f 73 65 20 | 5c 41 53 43 49 49 7b 7d |r whose |\ASCII{}|
|00000460| 20 63 6f 64 65 20 69 73 | 20 74 68 65 20 69 6e 74 | code is| the int|
|00000470| 65 67 65 72 0a 20 20 5c | 76 61 72 7b 69 7d 2c 20 |eger. \|var{i}, |
|00000480| 65 2e 67 2e 2c 20 5c 63 | 6f 64 65 7b 63 68 72 28 |e.g., \c|ode{chr(|
|00000490| 39 37 29 7d 20 72 65 74 | 75 72 6e 73 20 74 68 65 |97)} ret|urns the|
|000004a0| 20 73 74 72 69 6e 67 20 | 5c 63 6f 64 65 7b 27 61 | string |\code{'a|
|000004b0| 27 7d 2e 20 20 54 68 69 | 73 20 69 73 20 74 68 65 |'}. Thi|s is the|
|000004c0| 0a 20 20 69 6e 76 65 72 | 73 65 20 6f 66 20 5c 63 |. inver|se of \c|
|000004d0| 6f 64 65 7b 6f 72 64 28 | 29 7d 2e 20 20 54 68 65 |ode{ord(|)}. The|
|000004e0| 20 61 72 67 75 6d 65 6e | 74 20 6d 75 73 74 20 62 | argumen|t must b|
|000004f0| 65 20 69 6e 20 74 68 65 | 20 72 61 6e 67 65 20 5b |e in the| range [|
|00000500| 30 2e 2e 32 35 35 5d 2c | 0a 20 20 69 6e 63 6c 75 |0..255],|. inclu|
|00000510| 73 69 76 65 2e 0a 5c 65 | 6e 64 7b 66 75 6e 63 64 |sive..\e|nd{funcd|
|00000520| 65 73 63 7d 0a 0a 5c 62 | 65 67 69 6e 7b 66 75 6e |esc}..\b|egin{fun|
|00000530| 63 64 65 73 63 7d 7b 63 | 6d 70 7d 7b 78 5c 2c 20 |cdesc}{c|mp}{x\, |
|00000540| 79 7d 0a 20 20 43 6f 6d | 70 61 72 65 20 74 68 65 |y}. Com|pare the|
|00000550| 20 74 77 6f 20 6f 62 6a | 65 63 74 73 20 5c 76 61 | two obj|ects \va|
|00000560| 72 7b 78 7d 20 61 6e 64 | 20 5c 76 61 72 7b 79 7d |r{x} and| \var{y}|
|00000570| 20 61 6e 64 20 72 65 74 | 75 72 6e 20 61 6e 20 69 | and ret|urn an i|
|00000580| 6e 74 65 67 65 72 0a 20 | 20 61 63 63 6f 72 64 69 |nteger. | accordi|
|00000590| 6e 67 20 74 6f 20 74 68 | 65 20 6f 75 74 63 6f 6d |ng to th|e outcom|
|000005a0| 65 2e 20 20 54 68 65 20 | 72 65 74 75 72 6e 20 76 |e. The |return v|
|000005b0| 61 6c 75 65 20 69 73 20 | 6e 65 67 61 74 69 76 65 |alue is |negative|
|000005c0| 20 69 66 20 5c 63 6f 64 | 65 7b 5c 76 61 72 7b 78 | if \cod|e{\var{x|
|000005d0| 7d 0a 20 20 3c 20 5c 76 | 61 72 7b 79 7d 7d 2c 20 |}. < \v|ar{y}}, |
|000005e0| 7a 65 72 6f 20 69 66 20 | 5c 63 6f 64 65 7b 5c 76 |zero if |\code{\v|
|000005f0| 61 72 7b 78 7d 20 3d 3d | 20 5c 76 61 72 7b 79 7d |ar{x} ==| \var{y}|
|00000600| 7d 20 61 6e 64 20 73 74 | 72 69 63 74 6c 79 20 70 |} and st|rictly p|
|00000610| 6f 73 69 74 69 76 65 20 | 69 66 0a 20 20 5c 63 6f |ositive |if. \co|
|00000620| 64 65 7b 5c 76 61 72 7b | 78 7d 20 3e 20 5c 76 61 |de{\var{|x} > \va|
|00000630| 72 7b 79 7d 7d 2e 0a 5c | 65 6e 64 7b 66 75 6e 63 |r{y}}..\|end{func|
|00000640| 64 65 73 63 7d 0a 0a 5c | 62 65 67 69 6e 7b 66 75 |desc}..\|begin{fu|
|00000650| 6e 63 64 65 73 63 7d 7b | 63 6f 65 72 63 65 7d 7b |ncdesc}{|coerce}{|
|00000660| 78 5c 2c 20 79 7d 0a 20 | 20 52 65 74 75 72 6e 20 |x\, y}. | Return |
|00000670| 61 20 74 75 70 6c 65 20 | 63 6f 6e 73 69 73 74 69 |a tuple |consisti|
|00000680| 6e 67 20 6f 66 20 74 68 | 65 20 74 77 6f 20 6e 75 |ng of th|e two nu|
|00000690| 6d 65 72 69 63 20 61 72 | 67 75 6d 65 6e 74 73 20 |meric ar|guments |
|000006a0| 63 6f 6e 76 65 72 74 65 | 64 20 74 6f 0a 20 20 61 |converte|d to. a|
|000006b0| 20 63 6f 6d 6d 6f 6e 20 | 74 79 70 65 2c 20 75 73 | common |type, us|
|000006c0| 69 6e 67 20 74 68 65 20 | 73 61 6d 65 20 72 75 6c |ing the |same rul|
|000006d0| 65 73 20 61 73 20 75 73 | 65 64 20 62 79 20 61 72 |es as us|ed by ar|
|000006e0| 69 74 68 6d 65 74 69 63 | 0a 20 20 6f 70 65 72 61 |ithmetic|. opera|
|000006f0| 74 69 6f 6e 73 2e 0a 5c | 65 6e 64 7b 66 75 6e 63 |tions..\|end{func|
|00000700| 64 65 73 63 7d 0a 0a 5c | 62 65 67 69 6e 7b 66 75 |desc}..\|begin{fu|
|00000710| 6e 63 64 65 73 63 7d 7b | 63 6f 6d 70 69 6c 65 7d |ncdesc}{|compile}|
|00000720| 7b 73 74 72 69 6e 67 5c | 2c 20 66 69 6c 65 6e 61 |{string\|, filena|
|00000730| 6d 65 5c 2c 20 6b 69 6e | 64 7d 0a 20 20 43 6f 6d |me\, kin|d}. Com|
|00000740| 70 69 6c 65 20 74 68 65 | 20 5c 76 61 72 7b 73 74 |pile the| \var{st|
|00000750| 72 69 6e 67 7d 20 69 6e | 74 6f 20 61 20 63 6f 64 |ring} in|to a cod|
|00000760| 65 20 6f 62 6a 65 63 74 | 2e 20 20 43 6f 64 65 20 |e object|. Code |
|00000770| 6f 62 6a 65 63 74 73 20 | 63 61 6e 20 62 65 0a 20 |objects |can be. |
|00000780| 20 65 78 65 63 75 74 65 | 64 20 62 79 20 61 6e 20 | execute|d by an |
|00000790| 5c 63 6f 64 65 7b 65 78 | 65 63 7d 20 73 74 61 74 |\code{ex|ec} stat|
|000007a0| 65 6d 65 6e 74 20 6f 72 | 20 65 76 61 6c 75 61 74 |ement or| evaluat|
|000007b0| 65 64 20 62 79 20 61 20 | 63 61 6c 6c 20 74 6f 0a |ed by a |call to.|
|000007c0| 20 20 5c 63 6f 64 65 7b | 65 76 61 6c 28 29 7d 2e | \code{|eval()}.|
|000007d0| 20 20 54 68 65 20 5c 76 | 61 72 7b 66 69 6c 65 6e | The \v|ar{filen|
|000007e0| 61 6d 65 7d 20 61 72 67 | 75 6d 65 6e 74 20 73 68 |ame} arg|ument sh|
|000007f0| 6f 75 6c 64 0a 20 20 67 | 69 76 65 20 74 68 65 20 |ould. g|ive the |
|00000800| 66 69 6c 65 20 66 72 6f | 6d 20 77 68 69 63 68 20 |file fro|m which |
|00000810| 74 68 65 20 63 6f 64 65 | 20 77 61 73 20 72 65 61 |the code| was rea|
|00000820| 64 3b 20 70 61 73 73 20 | 65 2e 67 2e 20 5c 63 6f |d; pass |e.g. \co|
|00000830| 64 65 7b 27 3c 73 74 72 | 69 6e 67 3e 27 7d 0a 20 |de{'<str|ing>'}. |
|00000840| 20 69 66 20 69 74 20 77 | 61 73 6e 27 74 20 72 65 | if it w|asn't re|
|00000850| 61 64 20 66 72 6f 6d 20 | 61 20 66 69 6c 65 2e 20 |ad from |a file. |
|00000860| 20 54 68 65 20 5c 76 61 | 72 7b 6b 69 6e 64 7d 20 | The \va|r{kind} |
|00000870| 61 72 67 75 6d 65 6e 74 | 20 73 70 65 63 69 66 69 |argument| specifi|
|00000880| 65 73 0a 20 20 77 68 61 | 74 20 6b 69 6e 64 20 6f |es. wha|t kind o|
|00000890| 66 20 63 6f 64 65 20 6d | 75 73 74 20 62 65 20 63 |f code m|ust be c|
|000008a0| 6f 6d 70 69 6c 65 64 3b | 20 69 74 20 63 61 6e 20 |ompiled;| it can |
|000008b0| 62 65 20 5c 63 6f 64 65 | 7b 27 65 78 65 63 27 7d |be \code|{'exec'}|
|000008c0| 20 69 66 0a 20 20 5c 76 | 61 72 7b 73 74 72 69 6e | if. \v|ar{strin|
|000008d0| 67 7d 20 63 6f 6e 73 69 | 73 74 73 20 6f 66 20 61 |g} consi|sts of a|
|000008e0| 20 73 65 71 75 65 6e 63 | 65 20 6f 66 20 73 74 61 | sequenc|e of sta|
|000008f0| 74 65 6d 65 6e 74 73 2c | 20 5c 63 6f 64 65 7b 27 |tements,| \code{'|
|00000900| 65 76 61 6c 27 7d 0a 20 | 20 69 66 20 69 74 20 63 |eval'}. | if it c|
|00000910| 6f 6e 73 69 73 74 73 20 | 6f 66 20 61 20 73 69 6e |onsists |of a sin|
|00000920| 67 6c 65 20 65 78 70 72 | 65 73 73 69 6f 6e 2c 20 |gle expr|ession, |
|00000930| 6f 72 20 5c 63 6f 64 65 | 7b 27 73 69 6e 67 6c 65 |or \code|{'single|
|00000940| 27 7d 20 69 66 0a 20 20 | 69 74 20 63 6f 6e 73 69 |'} if. |it consi|
|00000950| 73 74 73 20 6f 66 20 61 | 20 73 69 6e 67 6c 65 20 |sts of a| single |
|00000960| 69 6e 74 65 72 61 63 74 | 69 76 65 20 73 74 61 74 |interact|ive stat|
|00000970| 65 6d 65 6e 74 20 28 69 | 6e 20 74 68 65 20 6c 61 |ement (i|n the la|
|00000980| 74 74 65 72 20 63 61 73 | 65 2c 0a 20 20 65 78 70 |tter cas|e,. exp|
|00000990| 72 65 73 73 69 6f 6e 20 | 73 74 61 74 65 6d 65 6e |ression |statemen|
|000009a0| 74 73 20 74 68 61 74 20 | 65 76 61 6c 75 61 74 65 |ts that |evaluate|
|000009b0| 20 74 6f 20 73 6f 6d 65 | 74 68 69 6e 67 20 65 6c | to some|thing el|
|000009c0| 73 65 20 74 68 61 6e 0a | 20 20 5c 63 6f 64 65 7b |se than.| \code{|
|000009d0| 4e 6f 6e 65 7d 20 77 69 | 6c 6c 20 70 72 69 6e 74 |None} wi|ll print|
|000009e0| 65 64 29 2e 0a 5c 65 6e | 64 7b 66 75 6e 63 64 65 |ed)..\en|d{funcde|
|000009f0| 73 63 7d 0a 0a 5c 62 65 | 67 69 6e 7b 66 75 6e 63 |sc}..\be|gin{func|
|00000a00| 64 65 73 63 7d 7b 64 65 | 6c 61 74 74 72 7d 7b 6f |desc}{de|lattr}{o|
|00000a10| 62 6a 65 63 74 5c 2c 20 | 6e 61 6d 65 7d 0a 20 20 |bject\, |name}. |
|00000a20| 54 68 69 73 20 69 73 20 | 61 20 72 65 6c 61 74 69 |This is |a relati|
|00000a30| 76 65 20 6f 66 20 5c 63 | 6f 64 65 7b 73 65 74 61 |ve of \c|ode{seta|
|00000a40| 74 74 72 7d 2e 20 20 54 | 68 65 20 61 72 67 75 6d |ttr}. T|he argum|
|00000a50| 65 6e 74 73 20 61 72 65 | 20 61 6e 0a 20 20 6f 62 |ents are| an. ob|
|00000a60| 6a 65 63 74 20 61 6e 64 | 20 61 20 73 74 72 69 6e |ject and| a strin|
|00000a70| 67 2e 20 20 54 68 65 20 | 73 74 72 69 6e 67 20 6d |g. The |string m|
|00000a80| 75 73 74 20 62 65 20 74 | 68 65 20 6e 61 6d 65 0a |ust be t|he name.|
|00000a90| 20 20 6f 66 20 6f 6e 65 | 20 6f 66 20 74 68 65 20 | of one| of the |
|00000aa0| 6f 62 6a 65 63 74 27 73 | 20 61 74 74 72 69 62 75 |object's| attribu|
|00000ab0| 74 65 73 2e 20 20 54 68 | 65 20 66 75 6e 63 74 69 |tes. Th|e functi|
|00000ac0| 6f 6e 20 64 65 6c 65 74 | 65 73 0a 20 20 74 68 65 |on delet|es. the|
|00000ad0| 20 6e 61 6d 65 64 20 61 | 74 74 72 69 62 75 74 65 | named a|ttribute|
|00000ae0| 2c 20 70 72 6f 76 69 64 | 65 64 20 74 68 65 20 6f |, provid|ed the o|
|00000af0| 62 6a 65 63 74 20 61 6c | 6c 6f 77 73 20 69 74 2e |bject al|lows it.|
|00000b00| 20 20 46 6f 72 20 65 78 | 61 6d 70 6c 65 2c 0a 20 | For ex|ample,. |
|00000b10| 20 5c 63 6f 64 65 7b 64 | 65 6c 61 74 74 72 28 5c | \code{d|elattr(\|
|00000b20| 76 61 72 7b 78 7d 2c 20 | 27 5c 76 61 72 7b 66 6f |var{x}, |'\var{fo|
|00000b30| 6f 62 61 72 7d 27 29 7d | 20 69 73 20 65 71 75 69 |obar}')}| is equi|
|00000b40| 76 61 6c 65 6e 74 20 74 | 6f 0a 20 20 5c 63 6f 64 |valent t|o. \cod|
|00000b50| 65 7b 64 65 6c 20 5c 76 | 61 72 7b 78 7d 2e 5c 76 |e{del \v|ar{x}.\v|
|00000b60| 61 72 7b 66 6f 6f 62 61 | 72 7d 7d 2e 0a 5c 65 6e |ar{fooba|r}}..\en|
|00000b70| 64 7b 66 75 6e 63 64 65 | 73 63 7d 0a 0a 5c 62 65 |d{funcde|sc}..\be|
|00000b80| 67 69 6e 7b 66 75 6e 63 | 64 65 73 63 7d 7b 64 69 |gin{func|desc}{di|
|00000b90| 72 7d 7b 7d 0a 20 20 57 | 69 74 68 6f 75 74 20 61 |r}{}. W|ithout a|
|00000ba0| 72 67 75 6d 65 6e 74 73 | 2c 20 72 65 74 75 72 6e |rguments|, return|
|00000bb0| 20 74 68 65 20 6c 69 73 | 74 20 6f 66 20 6e 61 6d | the lis|t of nam|
|00000bc0| 65 73 20 69 6e 20 74 68 | 65 20 63 75 72 72 65 6e |es in th|e curren|
|00000bd0| 74 20 6c 6f 63 61 6c 0a | 20 20 73 79 6d 62 6f 6c |t local.| symbol|
|00000be0| 20 74 61 62 6c 65 2e 20 | 20 57 69 74 68 20 61 20 | table. | With a |
|00000bf0| 6d 6f 64 75 6c 65 2c 20 | 63 6c 61 73 73 20 6f 72 |module, |class or|
|00000c00| 20 63 6c 61 73 73 20 69 | 6e 73 74 61 6e 63 65 20 | class i|nstance |
|00000c10| 6f 62 6a 65 63 74 20 61 | 73 0a 20 20 61 72 67 75 |object a|s. argu|
|00000c20| 6d 65 6e 74 20 28 6f 72 | 20 61 6e 79 74 68 69 6e |ment (or| anythin|
|00000c30| 67 20 65 6c 73 65 20 74 | 68 61 74 20 68 61 73 20 |g else t|hat has |
|00000c40| 61 20 5c 63 6f 64 65 7b | 5f 5f 64 69 63 74 5f 5f |a \code{|__dict__|
|00000c50| 7d 20 61 74 74 72 69 62 | 75 74 65 29 2c 0a 20 20 |} attrib|ute),. |
|00000c60| 72 65 74 75 72 6e 73 20 | 74 68 65 20 6c 69 73 74 |returns |the list|
|00000c70| 20 6f 66 20 6e 61 6d 65 | 73 20 69 6e 20 74 68 61 | of name|s in tha|
|00000c80| 74 20 6f 62 6a 65 63 74 | 27 73 20 61 74 74 72 69 |t object|'s attri|
|00000c90| 62 75 74 65 20 64 69 63 | 74 69 6f 6e 61 72 79 2e |bute dic|tionary.|
|00000ca0| 0a 20 20 54 68 65 20 72 | 65 73 75 6c 74 69 6e 67 |. The r|esulting|
|00000cb0| 20 6c 69 73 74 20 69 73 | 20 73 6f 72 74 65 64 2e | list is| sorted.|
|00000cc0| 20 20 46 6f 72 20 65 78 | 61 6d 70 6c 65 3a 0a 0a | For ex|ample:..|
|00000cd0| 5c 62 63 6f 64 65 5c 62 | 65 67 69 6e 7b 76 65 72 |\bcode\b|egin{ver|
|00000ce0| 62 61 74 69 6d 7d 0a 3e | 3e 3e 20 69 6d 70 6f 72 |batim}.>|>> impor|
|00000cf0| 74 20 73 79 73 0a 3e 3e | 3e 20 64 69 72 28 29 0a |t sys.>>|> dir().|
|00000d00| 5b 27 73 79 73 27 5d 0a | 3e 3e 3e 20 64 69 72 28 |['sys'].|>>> dir(|
|00000d10| 73 79 73 29 0a 5b 27 61 | 72 67 76 27 2c 20 27 65 |sys).['a|rgv', 'e|
|00000d20| 78 69 74 27 2c 20 27 6d | 6f 64 75 6c 65 73 27 2c |xit', 'm|odules',|
|00000d30| 20 27 70 61 74 68 27 2c | 20 27 73 74 64 65 72 72 | 'path',| 'stderr|
|00000d40| 27 2c 20 27 73 74 64 69 | 6e 27 2c 20 27 73 74 64 |', 'stdi|n', 'std|
|00000d50| 6f 75 74 27 5d 0a 3e 3e | 3e 20 0a 5c 65 6e 64 7b |out'].>>|> .\end{|
|00000d60| 76 65 72 62 61 74 69 6d | 7d 5c 65 63 6f 64 65 0a |verbatim|}\ecode.|
|00000d70| 5c 65 6e 64 7b 66 75 6e | 63 64 65 73 63 7d 0a 0a |\end{fun|cdesc}..|
|00000d80| 5c 62 65 67 69 6e 7b 66 | 75 6e 63 64 65 73 63 7d |\begin{f|uncdesc}|
|00000d90| 7b 64 69 76 6d 6f 64 7d | 7b 61 5c 2c 20 62 7d 0a |{divmod}|{a\, b}.|
|00000da0| 20 20 54 61 6b 65 20 74 | 77 6f 20 6e 75 6d 62 65 | Take t|wo numbe|
|00000db0| 72 73 20 61 73 20 61 72 | 67 75 6d 65 6e 74 73 20 |rs as ar|guments |
|00000dc0| 61 6e 64 20 72 65 74 75 | 72 6e 20 61 20 70 61 69 |and retu|rn a pai|
|00000dd0| 72 20 6f 66 20 69 6e 74 | 65 67 65 72 73 0a 20 20 |r of int|egers. |
|00000de0| 63 6f 6e 73 69 73 74 69 | 6e 67 20 6f 66 20 74 68 |consisti|ng of th|
|00000df0| 65 69 72 20 69 6e 74 65 | 67 65 72 20 71 75 6f 74 |eir inte|ger quot|
|00000e00| 69 65 6e 74 20 61 6e 64 | 20 72 65 6d 61 69 6e 64 |ient and| remaind|
|00000e10| 65 72 2e 20 20 57 69 74 | 68 20 6d 69 78 65 64 0a |er. Wit|h mixed.|
|00000e20| 20 20 6f 70 65 72 61 6e | 64 20 74 79 70 65 73 2c | operan|d types,|
|00000e30| 20 74 68 65 20 72 75 6c | 65 73 20 66 6f 72 20 62 | the rul|es for b|
|00000e40| 69 6e 61 72 79 20 61 72 | 69 74 68 6d 65 74 69 63 |inary ar|ithmetic|
|00000e50| 20 6f 70 65 72 61 74 6f | 72 73 20 61 70 70 6c 79 | operato|rs apply|
|00000e60| 2e 20 20 46 6f 72 0a 20 | 20 70 6c 61 69 6e 20 61 |. For. | plain a|
|00000e70| 6e 64 20 6c 6f 6e 67 20 | 69 6e 74 65 67 65 72 73 |nd long |integers|
|00000e80| 2c 20 74 68 65 20 72 65 | 73 75 6c 74 20 69 73 20 |, the re|sult is |
|00000e90| 74 68 65 20 73 61 6d 65 | 20 61 73 0a 20 20 5c 63 |the same| as. \c|
|00000ea0| 6f 64 65 7b 28 5c 76 61 | 72 7b 61 7d 20 2f 20 5c |ode{(\va|r{a} / \|
|00000eb0| 76 61 72 7b 62 7d 2c 20 | 5c 76 61 72 7b 61 7d 20 |var{b}, |\var{a} |
|00000ec0| 5c 25 7b 7d 20 5c 76 61 | 72 7b 62 7d 29 7d 2e 0a |\%{} \va|r{b})}..|
|00000ed0| 20 20 46 6f 72 20 66 6c | 6f 61 74 69 6e 67 20 70 | For fl|oating p|
|00000ee0| 6f 69 6e 74 20 6e 75 6d | 62 65 72 73 20 74 68 65 |oint num|bers the|
|00000ef0| 20 72 65 73 75 6c 74 20 | 69 73 20 74 68 65 20 73 | result |is the s|
|00000f00| 61 6d 65 20 61 73 0a 20 | 20 5c 63 6f 64 65 7b 28 |ame as. | \code{(|
|00000f10| 6d 61 74 68 2e 66 6c 6f | 6f 72 28 5c 76 61 72 7b |math.flo|or(\var{|
|00000f20| 61 7d 20 2f 20 5c 76 61 | 72 7b 62 7d 29 2c 20 5c |a} / \va|r{b}), \|
|00000f30| 76 61 72 7b 61 7d 20 5c | 25 7b 7d 20 5c 76 61 72 |var{a} \|%{} \var|
|00000f40| 7b 62 7d 29 7d 2e 0a 5c | 65 6e 64 7b 66 75 6e 63 |{b})}..\|end{func|
|00000f50| 64 65 73 63 7d 0a 0a 5c | 62 65 67 69 6e 7b 66 75 |desc}..\|begin{fu|
|00000f60| 6e 63 64 65 73 63 7d 7b | 65 76 61 6c 7d 7b 65 78 |ncdesc}{|eval}{ex|
|00000f70| 70 72 65 73 73 69 6f 6e | 5c 6f 70 74 69 6f 6e 61 |pression|\optiona|
|00000f80| 6c 7b 5c 2c 20 67 6c 6f | 62 61 6c 73 5c 6f 70 74 |l{\, glo|bals\opt|
|00000f90| 69 6f 6e 61 6c 7b 5c 2c | 20 6c 6f 63 61 6c 73 7d |ional{\,| locals}|
|00000fa0| 7d 7d 0a 20 20 54 68 65 | 20 61 72 67 75 6d 65 6e |}}. The| argumen|
|00000fb0| 74 73 20 61 72 65 20 61 | 20 73 74 72 69 6e 67 20 |ts are a| string |
|00000fc0| 61 6e 64 20 74 77 6f 20 | 6f 70 74 69 6f 6e 61 6c |and two |optional|
|00000fd0| 20 64 69 63 74 69 6f 6e | 61 72 69 65 73 2e 20 20 | diction|aries. |
|00000fe0| 54 68 65 0a 20 20 5c 76 | 61 72 7b 65 78 70 72 65 |The. \v|ar{expre|
|00000ff0| 73 73 69 6f 6e 7d 20 61 | 72 67 75 6d 65 6e 74 20 |ssion} a|rgument |
|00001000| 69 73 20 70 61 72 73 65 | 64 20 61 6e 64 20 65 76 |is parse|d and ev|
|00001010| 61 6c 75 61 74 65 64 20 | 61 73 20 61 20 50 79 74 |aluated |as a Pyt|
|00001020| 68 6f 6e 0a 20 20 65 78 | 70 72 65 73 73 69 6f 6e |hon. ex|pression|
|00001030| 20 28 74 65 63 68 6e 69 | 63 61 6c 6c 79 20 73 70 | (techni|cally sp|
|00001040| 65 61 6b 69 6e 67 2c 20 | 61 20 63 6f 6e 64 69 74 |eaking, |a condit|
|00001050| 69 6f 6e 20 6c 69 73 74 | 29 20 75 73 69 6e 67 20 |ion list|) using |
|00001060| 74 68 65 0a 20 20 5c 76 | 61 72 7b 67 6c 6f 62 61 |the. \v|ar{globa|
|00001070| 6c 73 7d 20 61 6e 64 20 | 5c 76 61 72 7b 6c 6f 63 |ls} and |\var{loc|
|00001080| 61 6c 73 7d 20 64 69 63 | 74 69 6f 6e 61 72 69 65 |als} dic|tionarie|
|00001090| 73 20 61 73 20 67 6c 6f | 62 61 6c 20 61 6e 64 20 |s as glo|bal and |
|000010a0| 6c 6f 63 61 6c 20 6e 61 | 6d 65 0a 20 20 73 70 61 |local na|me. spa|
|000010b0| 63 65 2e 20 20 49 66 20 | 74 68 65 20 5c 76 61 72 |ce. If |the \var|
|000010c0| 7b 6c 6f 63 61 6c 73 7d | 20 64 69 63 74 69 6f 6e |{locals}| diction|
|000010d0| 61 72 79 20 69 73 20 6f | 6d 69 74 74 65 64 20 69 |ary is o|mitted i|
|000010e0| 74 20 64 65 66 61 75 6c | 74 73 20 74 6f 0a 20 20 |t defaul|ts to. |
|000010f0| 74 68 65 20 5c 76 61 72 | 7b 67 6c 6f 62 61 6c 73 |the \var|{globals|
|00001100| 7d 20 64 69 63 74 69 6f | 6e 61 72 79 2e 20 20 49 |} dictio|nary. I|
|00001110| 66 20 62 6f 74 68 20 64 | 69 63 74 69 6f 6e 61 72 |f both d|ictionar|
|00001120| 69 65 73 20 61 72 65 20 | 6f 6d 69 74 74 65 64 2c |ies are |omitted,|
|00001130| 20 74 68 65 0a 20 20 65 | 78 70 72 65 73 73 69 6f | the. e|xpressio|
|00001140| 6e 20 69 73 20 65 78 65 | 63 75 74 65 64 20 69 6e |n is exe|cuted in|
|00001150| 20 74 68 65 20 65 6e 76 | 69 72 6f 6e 6d 65 6e 74 | the env|ironment|
|00001160| 20 77 68 65 72 65 20 5c | 63 6f 64 65 7b 65 76 61 | where \|code{eva|
|00001170| 6c 7d 20 69 73 0a 20 20 | 63 61 6c 6c 65 64 2e 20 |l} is. |called. |
|00001180| 20 54 68 65 20 72 65 74 | 75 72 6e 20 76 61 6c 75 | The ret|urn valu|
|00001190| 65 20 69 73 20 74 68 65 | 20 72 65 73 75 6c 74 20 |e is the| result |
|000011a0| 6f 66 20 74 68 65 20 65 | 76 61 6c 75 61 74 65 64 |of the e|valuated|
|000011b0| 20 65 78 70 72 65 73 73 | 69 6f 6e 2e 0a 20 20 53 | express|ion.. S|
|000011c0| 79 6e 74 61 78 20 65 72 | 72 6f 72 73 20 61 72 65 |yntax er|rors are|
|000011d0| 20 72 65 70 6f 72 74 65 | 64 20 61 73 20 65 78 63 | reporte|d as exc|
|000011e0| 65 70 74 69 6f 6e 73 2e | 20 20 45 78 61 6d 70 6c |eptions.| Exampl|
|000011f0| 65 3a 0a 0a 5c 62 63 6f | 64 65 5c 62 65 67 69 6e |e:..\bco|de\begin|
|00001200| 7b 76 65 72 62 61 74 69 | 6d 7d 0a 3e 3e 3e 20 78 |{verbati|m}.>>> x|
|00001210| 20 3d 20 31 0a 3e 3e 3e | 20 70 72 69 6e 74 20 65 | = 1.>>>| print e|
|00001220| 76 61 6c 28 27 78 2b 31 | 27 29 0a 32 0a 3e 3e 3e |val('x+1|').2.>>>|
|00001230| 20 0a 5c 65 6e 64 7b 76 | 65 72 62 61 74 69 6d 7d | .\end{v|erbatim}|
|00001240| 5c 65 63 6f 64 65 0a 0a | 20 20 54 68 69 73 20 66 |\ecode..| This f|
|00001250| 75 6e 63 74 69 6f 6e 20 | 63 61 6e 20 61 6c 73 6f |unction |can also|
|00001260| 20 62 65 20 75 73 65 64 | 20 74 6f 20 65 78 65 63 | be used| to exec|
|00001270| 75 74 65 20 61 72 62 69 | 74 72 61 72 79 20 63 6f |ute arbi|trary co|
|00001280| 64 65 20 6f 62 6a 65 63 | 74 73 0a 20 20 28 65 2e |de objec|ts. (e.|
|00001290| 67 2e 5c 20 63 72 65 61 | 74 65 64 20 62 79 20 5c |g.\ crea|ted by \|
|000012a0| 63 6f 64 65 7b 63 6f 6d | 70 69 6c 65 28 29 7d 29 |code{com|pile()})|
|000012b0| 2e 20 20 49 6e 20 74 68 | 69 73 20 63 61 73 65 20 |. In th|is case |
|000012c0| 70 61 73 73 20 61 20 63 | 6f 64 65 0a 20 20 6f 62 |pass a c|ode. ob|
|000012d0| 6a 65 63 74 20 69 6e 73 | 74 65 61 64 20 6f 66 20 |ject ins|tead of |
|000012e0| 61 20 73 74 72 69 6e 67 | 2e 20 20 54 68 65 20 63 |a string|. The c|
|000012f0| 6f 64 65 20 6f 62 6a 65 | 63 74 20 6d 75 73 74 20 |ode obje|ct must |
|00001300| 68 61 76 65 20 62 65 65 | 6e 20 63 6f 6d 70 69 6c |have bee|n compil|
|00001310| 65 64 0a 20 20 70 61 73 | 73 69 6e 67 20 5c 63 6f |ed. pas|sing \co|
|00001320| 64 65 7b 27 65 76 61 6c | 27 7d 20 74 6f 20 74 68 |de{'eval|'} to th|
|00001330| 65 20 5c 76 61 72 7b 6b | 69 6e 64 7d 20 61 72 67 |e \var{k|ind} arg|
|00001340| 75 6d 65 6e 74 2e 0a 0a | 20 20 48 69 6e 74 73 3a |ument...| Hints:|
|00001350| 20 64 79 6e 61 6d 69 63 | 20 65 78 65 63 75 74 69 | dynamic| executi|
|00001360| 6f 6e 20 6f 66 20 73 74 | 61 74 65 6d 65 6e 74 73 |on of st|atements|
|00001370| 20 69 73 20 73 75 70 70 | 6f 72 74 65 64 20 62 79 | is supp|orted by|
|00001380| 20 74 68 65 0a 20 20 5c | 63 6f 64 65 7b 65 78 65 | the. \|code{exe|
|00001390| 63 7d 20 73 74 61 74 65 | 6d 65 6e 74 2e 20 20 45 |c} state|ment. E|
|000013a0| 78 65 63 75 74 69 6f 6e | 20 6f 66 20 73 74 61 74 |xecution| of stat|
|000013b0| 65 6d 65 6e 74 73 20 66 | 72 6f 6d 20 61 20 66 69 |ements f|rom a fi|
|000013c0| 6c 65 20 69 73 0a 20 20 | 73 75 70 70 6f 72 74 65 |le is. |supporte|
|000013d0| 64 20 62 79 20 74 68 65 | 20 5c 63 6f 64 65 7b 65 |d by the| \code{e|
|000013e0| 78 65 63 66 69 6c 65 28 | 29 7d 20 66 75 6e 63 74 |xecfile(|)} funct|
|000013f0| 69 6f 6e 2e 20 20 54 68 | 65 20 5c 63 6f 64 65 7b |ion. Th|e \code{|
|00001400| 67 6c 6f 62 61 6c 73 28 | 29 7d 0a 20 20 61 6e 64 |globals(|)}. and|
|00001410| 20 5c 63 6f 64 65 7b 6c | 6f 63 61 6c 73 28 29 7d | \code{l|ocals()}|
|00001420| 20 66 75 6e 63 74 69 6f | 6e 73 20 72 65 74 75 72 | functio|ns retur|
|00001430| 6e 73 20 74 68 65 20 63 | 75 72 72 65 6e 74 20 67 |ns the c|urrent g|
|00001440| 6c 6f 62 61 6c 20 61 6e | 64 20 6c 6f 63 61 6c 0a |lobal an|d local.|
|00001450| 20 20 64 69 63 74 69 6f | 6e 61 72 79 2c 20 72 65 | dictio|nary, re|
|00001460| 73 70 65 63 74 69 76 65 | 6c 79 2c 20 77 68 69 63 |spective|ly, whic|
|00001470| 68 20 6d 61 79 20 62 65 | 20 75 73 65 66 75 6c 0a |h may be| useful.|
|00001480| 20 20 74 6f 20 70 61 73 | 73 20 61 72 6f 75 6e 64 | to pas|s around|
|00001490| 20 66 6f 72 20 75 73 65 | 20 62 79 20 5c 63 6f 64 | for use| by \cod|
|000014a0| 65 7b 65 76 61 6c 28 29 | 7d 20 6f 72 20 5c 63 6f |e{eval()|} or \co|
|000014b0| 64 65 7b 65 78 65 63 66 | 69 6c 65 28 29 7d 2e 0a |de{execf|ile()}..|
|000014c0| 0a 5c 65 6e 64 7b 66 75 | 6e 63 64 65 73 63 7d 0a |.\end{fu|ncdesc}.|
|000014d0| 0a 5c 62 65 67 69 6e 7b | 66 75 6e 63 64 65 73 63 |.\begin{|funcdesc|
|000014e0| 7d 7b 65 78 65 63 66 69 | 6c 65 7d 7b 66 69 6c 65 |}{execfi|le}{file|
|000014f0| 5c 6f 70 74 69 6f 6e 61 | 6c 7b 5c 2c 20 67 6c 6f |\optiona|l{\, glo|
|00001500| 62 61 6c 73 5c 6f 70 74 | 69 6f 6e 61 6c 7b 5c 2c |bals\opt|ional{\,|
|00001510| 20 6c 6f 63 61 6c 73 7d | 7d 7d 0a 20 20 54 68 69 | locals}|}}. Thi|
|00001520| 73 20 66 75 6e 63 74 69 | 6f 6e 20 69 73 20 73 69 |s functi|on is si|
|00001530| 6d 69 6c 61 72 20 74 6f | 20 74 68 65 0a 20 20 5c |milar to| the. \|
|00001540| 63 6f 64 65 7b 65 78 65 | 63 7d 20 73 74 61 74 65 |code{exe|c} state|
|00001550| 6d 65 6e 74 2c 20 62 75 | 74 20 70 61 72 73 65 73 |ment, bu|t parses|
|00001560| 20 61 20 66 69 6c 65 20 | 69 6e 73 74 65 61 64 20 | a file |instead |
|00001570| 6f 66 20 61 20 73 74 72 | 69 6e 67 2e 20 20 49 74 |of a str|ing. It|
|00001580| 20 69 73 0a 20 20 64 69 | 66 66 65 72 65 6e 74 20 | is. di|fferent |
|00001590| 66 72 6f 6d 20 74 68 65 | 20 5c 63 6f 64 65 7b 69 |from the| \code{i|
|000015a0| 6d 70 6f 72 74 7d 20 73 | 74 61 74 65 6d 65 6e 74 |mport} s|tatement|
|000015b0| 20 69 6e 20 74 68 61 74 | 20 69 74 20 64 6f 65 73 | in that| it does|
|000015c0| 20 6e 6f 74 20 75 73 65 | 0a 20 20 74 68 65 20 6d | not use|. the m|
|000015d0| 6f 64 75 6c 65 20 61 64 | 6d 69 6e 69 73 74 72 61 |odule ad|ministra|
|000015e0| 74 69 6f 6e 20 2d 2d 2d | 20 69 74 20 72 65 61 64 |tion ---| it read|
|000015f0| 73 20 74 68 65 20 66 69 | 6c 65 20 75 6e 63 6f 6e |s the fi|le uncon|
|00001600| 64 69 74 69 6f 6e 61 6c | 6c 79 20 61 6e 64 0a 20 |ditional|ly and. |
|00001610| 20 64 6f 65 73 20 6e 6f | 74 20 63 72 65 61 74 65 | does no|t create|
|00001620| 20 61 20 6e 65 77 20 6d | 6f 64 75 6c 65 2e 5c 66 | a new m|odule.\f|
|00001630| 6f 6f 74 6e 6f 74 65 7b | 49 74 20 69 73 20 75 73 |ootnote{|It is us|
|00001640| 65 64 20 72 65 6c 61 74 | 69 76 65 6c 79 20 72 61 |ed relat|ively ra|
|00001650| 72 65 6c 79 0a 20 20 73 | 6f 20 64 6f 65 73 20 6e |rely. s|o does n|
|00001660| 6f 74 20 77 61 72 72 61 | 6e 74 20 62 65 69 6e 67 |ot warra|nt being|
|00001670| 20 6d 61 64 65 20 69 6e | 74 6f 20 61 20 73 74 61 | made in|to a sta|
|00001680| 74 65 6d 65 6e 74 2e 7d | 0a 0a 20 20 54 68 65 20 |tement.}|.. The |
|00001690| 61 72 67 75 6d 65 6e 74 | 73 20 61 72 65 20 61 20 |argument|s are a |
|000016a0| 66 69 6c 65 20 6e 61 6d | 65 20 61 6e 64 20 74 77 |file nam|e and tw|
|000016b0| 6f 20 6f 70 74 69 6f 6e | 61 6c 20 64 69 63 74 69 |o option|al dicti|
|000016c0| 6f 6e 61 72 69 65 73 2e | 20 20 54 68 65 0a 20 20 |onaries.| The. |
|000016d0| 66 69 6c 65 20 69 73 20 | 70 61 72 73 65 64 20 61 |file is |parsed a|
|000016e0| 6e 64 20 65 76 61 6c 75 | 61 74 65 64 20 61 73 20 |nd evalu|ated as |
|000016f0| 61 20 73 65 71 75 65 6e | 63 65 20 6f 66 20 50 79 |a sequen|ce of Py|
|00001700| 74 68 6f 6e 20 73 74 61 | 74 65 6d 65 6e 74 73 0a |thon sta|tements.|
|00001710| 20 20 28 73 69 6d 69 6c | 61 72 6c 79 20 74 6f 20 | (simil|arly to |
|00001720| 61 20 6d 6f 64 75 6c 65 | 29 20 75 73 69 6e 67 20 |a module|) using |
|00001730| 74 68 65 20 5c 76 61 72 | 7b 67 6c 6f 62 61 6c 73 |the \var|{globals|
|00001740| 7d 20 61 6e 64 20 5c 76 | 61 72 7b 6c 6f 63 61 6c |} and \v|ar{local|
|00001750| 73 7d 0a 20 20 64 69 63 | 74 69 6f 6e 61 72 69 65 |s}. dic|tionarie|
|00001760| 73 20 61 73 20 67 6c 6f | 62 61 6c 20 61 6e 64 20 |s as glo|bal and |
|00001770| 6c 6f 63 61 6c 20 6e 61 | 6d 65 20 73 70 61 63 65 |local na|me space|
|00001780| 2e 20 20 49 66 20 74 68 | 65 20 5c 76 61 72 7b 6c |. If th|e \var{l|
|00001790| 6f 63 61 6c 73 7d 0a 20 | 20 64 69 63 74 69 6f 6e |ocals}. | diction|
|000017a0| 61 72 79 20 69 73 20 6f | 6d 69 74 74 65 64 20 69 |ary is o|mitted i|
|000017b0| 74 20 64 65 66 61 75 6c | 74 73 20 74 6f 20 74 68 |t defaul|ts to th|
|000017c0| 65 20 5c 76 61 72 7b 67 | 6c 6f 62 61 6c 73 7d 20 |e \var{g|lobals} |
|000017d0| 64 69 63 74 69 6f 6e 61 | 72 79 2e 0a 20 20 49 66 |dictiona|ry.. If|
|000017e0| 20 62 6f 74 68 20 64 69 | 63 74 69 6f 6e 61 72 69 | both di|ctionari|
|000017f0| 65 73 20 61 72 65 20 6f | 6d 69 74 74 65 64 2c 20 |es are o|mitted, |
|00001800| 74 68 65 20 65 78 70 72 | 65 73 73 69 6f 6e 20 69 |the expr|ession i|
|00001810| 73 20 65 78 65 63 75 74 | 65 64 20 69 6e 20 74 68 |s execut|ed in th|
|00001820| 65 0a 20 20 65 6e 76 69 | 72 6f 6e 6d 65 6e 74 20 |e. envi|ronment |
|00001830| 77 68 65 72 65 20 5c 63 | 6f 64 65 7b 65 78 65 63 |where \c|ode{exec|
|00001840| 66 69 6c 65 28 29 7d 20 | 69 73 20 63 61 6c 6c 65 |file()} |is calle|
|00001850| 64 2e 20 20 54 68 65 20 | 72 65 74 75 72 6e 20 76 |d. The |return v|
|00001860| 61 6c 75 65 20 69 73 0a | 20 20 5c 63 6f 64 65 7b |alue is.| \code{|
|00001870| 4e 6f 6e 65 7d 2e 0a 5c | 65 6e 64 7b 66 75 6e 63 |None}..\|end{func|
|00001880| 64 65 73 63 7d 0a 0a 5c | 62 65 67 69 6e 7b 66 75 |desc}..\|begin{fu|
|00001890| 6e 63 64 65 73 63 7d 7b | 66 69 6c 74 65 72 7d 7b |ncdesc}{|filter}{|
|000018a0| 66 75 6e 63 74 69 6f 6e | 5c 2c 20 6c 69 73 74 7d |function|\, list}|
|000018b0| 0a 43 6f 6e 73 74 72 75 | 63 74 20 61 20 6c 69 73 |.Constru|ct a lis|
|000018c0| 74 20 66 72 6f 6d 20 74 | 68 6f 73 65 20 65 6c 65 |t from t|hose ele|
|000018d0| 6d 65 6e 74 73 20 6f 66 | 20 5c 76 61 72 7b 6c 69 |ments of| \var{li|
|000018e0| 73 74 7d 20 66 6f 72 20 | 77 68 69 63 68 0a 5c 76 |st} for |which.\v|
|000018f0| 61 72 7b 66 75 6e 63 74 | 69 6f 6e 7d 20 72 65 74 |ar{funct|ion} ret|
|00001900| 75 72 6e 73 20 74 72 75 | 65 2e 20 20 49 66 20 5c |urns tru|e. If \|
|00001910| 76 61 72 7b 6c 69 73 74 | 7d 20 69 73 20 61 20 73 |var{list|} is a s|
|00001920| 74 72 69 6e 67 20 6f 72 | 20 61 20 74 75 70 6c 65 |tring or| a tuple|
|00001930| 2c 0a 74 68 65 20 72 65 | 73 75 6c 74 20 61 6c 73 |,.the re|sult als|
|00001940| 6f 20 68 61 73 20 74 68 | 61 74 20 74 79 70 65 3b |o has th|at type;|
|00001950| 20 6f 74 68 65 72 77 69 | 73 65 20 69 74 20 69 73 | otherwi|se it is|
|00001960| 20 61 6c 77 61 79 73 20 | 61 20 6c 69 73 74 2e 20 | always |a list. |
|00001970| 20 49 66 0a 5c 76 61 72 | 7b 66 75 6e 63 74 69 6f | If.\var|{functio|
|00001980| 6e 7d 20 69 73 20 5c 63 | 6f 64 65 7b 4e 6f 6e 65 |n} is \c|ode{None|
|00001990| 7d 2c 20 74 68 65 20 69 | 64 65 6e 74 69 74 79 20 |}, the i|dentity |
|000019a0| 66 75 6e 63 74 69 6f 6e | 20 69 73 20 61 73 73 75 |function| is assu|
|000019b0| 6d 65 64 2c 0a 69 2e 65 | 2e 5c 20 61 6c 6c 20 65 |med,.i.e|.\ all e|
|000019c0| 6c 65 6d 65 6e 74 73 20 | 6f 66 20 5c 76 61 72 7b |lements |of \var{|
|000019d0| 6c 69 73 74 7d 20 74 68 | 61 74 20 61 72 65 20 66 |list} th|at are f|
|000019e0| 61 6c 73 65 20 28 7a 65 | 72 6f 20 6f 72 20 65 6d |alse (ze|ro or em|
|000019f0| 70 74 79 29 20 61 72 65 | 0a 72 65 6d 6f 76 65 64 |pty) are|.removed|
|00001a00| 2e 0a 5c 65 6e 64 7b 66 | 75 6e 63 64 65 73 63 7d |..\end{f|uncdesc}|
|00001a10| 0a 0a 5c 62 65 67 69 6e | 7b 66 75 6e 63 64 65 73 |..\begin|{funcdes|
|00001a20| 63 7d 7b 66 6c 6f 61 74 | 7d 7b 78 7d 0a 20 20 43 |c}{float|}{x}. C|
|00001a30| 6f 6e 76 65 72 74 20 61 | 20 6e 75 6d 62 65 72 20 |onvert a| number |
|00001a40| 74 6f 20 66 6c 6f 61 74 | 69 6e 67 20 70 6f 69 6e |to float|ing poin|
|00001a50| 74 2e 20 20 54 68 65 20 | 61 72 67 75 6d 65 6e 74 |t. The |argument|
|00001a60| 20 6d 61 79 20 62 65 20 | 61 20 70 6c 61 69 6e 20 | may be |a plain |
|00001a70| 6f 72 0a 20 20 6c 6f 6e | 67 20 69 6e 74 65 67 65 |or. lon|g intege|
|00001a80| 72 20 6f 72 20 61 20 66 | 6c 6f 61 74 69 6e 67 20 |r or a f|loating |
|00001a90| 70 6f 69 6e 74 20 6e 75 | 6d 62 65 72 2e 0a 5c 65 |point nu|mber..\e|
|00001aa0| 6e 64 7b 66 75 6e 63 64 | 65 73 63 7d 0a 0a 5c 62 |nd{funcd|esc}..\b|
|00001ab0| 65 67 69 6e 7b 66 75 6e | 63 64 65 73 63 7d 7b 67 |egin{fun|cdesc}{g|
|00001ac0| 65 74 61 74 74 72 7d 7b | 6f 62 6a 65 63 74 5c 2c |etattr}{|object\,|
|00001ad0| 20 6e 61 6d 65 7d 0a 20 | 20 54 68 65 20 61 72 67 | name}. | The arg|
|00001ae0| 75 6d 65 6e 74 73 20 61 | 72 65 20 61 6e 20 6f 62 |uments a|re an ob|
|00001af0| 6a 65 63 74 20 61 6e 64 | 20 61 20 73 74 72 69 6e |ject and| a strin|
|00001b00| 67 2e 20 20 54 68 65 20 | 73 74 72 69 6e 67 20 6d |g. The |string m|
|00001b10| 75 73 74 20 62 65 20 74 | 68 65 0a 20 20 6e 61 6d |ust be t|he. nam|
|00001b20| 65 0a 20 20 6f 66 20 6f | 6e 65 20 6f 66 20 74 68 |e. of o|ne of th|
|00001b30| 65 20 6f 62 6a 65 63 74 | 27 73 20 61 74 74 72 69 |e object|'s attri|
|00001b40| 62 75 74 65 73 2e 20 20 | 54 68 65 20 72 65 73 75 |butes. |The resu|
|00001b50| 6c 74 20 69 73 20 74 68 | 65 20 76 61 6c 75 65 20 |lt is th|e value |
|00001b60| 6f 66 20 74 68 61 74 0a | 20 20 61 74 74 72 69 62 |of that.| attrib|
|00001b70| 75 74 65 2e 20 20 46 6f | 72 20 65 78 61 6d 70 6c |ute. Fo|r exampl|
|00001b80| 65 2c 20 5c 63 6f 64 65 | 7b 67 65 74 61 74 74 72 |e, \code|{getattr|
|00001b90| 28 5c 76 61 72 7b 78 7d | 2c 20 27 5c 76 61 72 7b |(\var{x}|, '\var{|
|00001ba0| 66 6f 6f 62 61 72 7d 27 | 29 7d 20 69 73 20 65 71 |foobar}'|)} is eq|
|00001bb0| 75 69 76 61 6c 65 6e 74 | 20 74 6f 0a 20 20 5c 63 |uivalent| to. \c|
|00001bc0| 6f 64 65 7b 5c 76 61 72 | 7b 78 7d 2e 5c 76 61 72 |ode{\var|{x}.\var|
|00001bd0| 7b 66 6f 6f 62 61 72 7d | 7d 2e 0a 5c 65 6e 64 7b |{foobar}|}..\end{|
|00001be0| 66 75 6e 63 64 65 73 63 | 7d 0a 0a 5c 62 65 67 69 |funcdesc|}..\begi|
|00001bf0| 6e 7b 66 75 6e 63 64 65 | 73 63 7d 7b 67 6c 6f 62 |n{funcde|sc}{glob|
|00001c00| 61 6c 73 7d 7b 7d 0a 52 | 65 74 75 72 6e 20 61 20 |als}{}.R|eturn a |
|00001c10| 64 69 63 74 69 6f 6e 61 | 72 79 20 72 65 70 72 65 |dictiona|ry repre|
|00001c20| 73 65 6e 74 69 6e 67 20 | 74 68 65 20 63 75 72 72 |senting |the curr|
|00001c30| 65 6e 74 20 67 6c 6f 62 | 61 6c 20 73 79 6d 62 6f |ent glob|al symbo|
|00001c40| 6c 20 74 61 62 6c 65 2e | 0a 54 68 69 73 20 69 73 |l table.|.This is|
|00001c50| 20 61 6c 77 61 79 73 20 | 74 68 65 20 64 69 63 74 | always |the dict|
|00001c60| 69 6f 6e 61 72 79 20 6f | 66 20 74 68 65 20 63 75 |ionary o|f the cu|
|00001c70| 72 72 65 6e 74 20 6d 6f | 64 75 6c 65 20 28 69 6e |rrent mo|dule (in|
|00001c80| 73 69 64 65 20 61 0a 66 | 75 6e 63 74 69 6f 6e 20 |side a.f|unction |
|00001c90| 6f 72 20 6d 65 74 68 6f | 64 2c 20 74 68 69 73 20 |or metho|d, this |
|00001ca0| 69 73 20 74 68 65 20 6d | 6f 64 75 6c 65 20 77 68 |is the m|odule wh|
|00001cb0| 65 72 65 20 69 74 20 69 | 73 20 64 65 66 69 6e 65 |ere it i|s define|
|00001cc0| 64 2c 20 6e 6f 74 20 74 | 68 65 0a 6d 6f 64 75 6c |d, not t|he.modul|
|00001cd0| 65 20 66 72 6f 6d 20 77 | 68 69 63 68 20 69 74 20 |e from w|hich it |
|00001ce0| 69 73 20 63 61 6c 6c 65 | 64 29 2e 0a 5c 65 6e 64 |is calle|d)..\end|
|00001cf0| 7b 66 75 6e 63 64 65 73 | 63 7d 0a 0a 5c 62 65 67 |{funcdes|c}..\beg|
|00001d00| 69 6e 7b 66 75 6e 63 64 | 65 73 63 7d 7b 68 61 73 |in{funcd|esc}{has|
|00001d10| 61 74 74 72 7d 7b 6f 62 | 6a 65 63 74 5c 2c 20 6e |attr}{ob|ject\, n|
|00001d20| 61 6d 65 7d 0a 20 20 54 | 68 65 20 61 72 67 75 6d |ame}. T|he argum|
|00001d30| 65 6e 74 73 20 61 72 65 | 20 61 6e 20 6f 62 6a 65 |ents are| an obje|
|00001d40| 63 74 20 61 6e 64 20 61 | 20 73 74 72 69 6e 67 2e |ct and a| string.|
|00001d50| 20 20 54 68 65 20 72 65 | 73 75 6c 74 20 69 73 20 | The re|sult is |
|00001d60| 31 20 69 66 20 74 68 65 | 0a 20 20 73 74 72 69 6e |1 if the|. strin|
|00001d70| 67 20 69 73 20 74 68 65 | 20 6e 61 6d 65 20 6f 66 |g is the| name of|
|00001d80| 20 6f 6e 65 20 6f 66 20 | 74 68 65 20 6f 62 6a 65 | one of |the obje|
|00001d90| 63 74 27 73 20 61 74 74 | 72 69 62 75 74 65 73 2c |ct's att|ributes,|
|00001da0| 20 30 20 69 66 20 6e 6f | 74 2e 0a 20 20 28 54 68 | 0 if no|t.. (Th|
|00001db0| 69 73 20 69 73 20 69 6d | 70 6c 65 6d 65 6e 74 65 |is is im|plemente|
|00001dc0| 64 20 62 79 20 63 61 6c | 6c 69 6e 67 20 5c 63 6f |d by cal|ling \co|
|00001dd0| 64 65 7b 67 65 74 61 74 | 74 72 28 6f 62 6a 65 63 |de{getat|tr(objec|
|00001de0| 74 2c 20 6e 61 6d 65 29 | 7d 20 61 6e 64 0a 20 20 |t, name)|} and. |
|00001df0| 73 65 65 69 6e 67 20 77 | 68 65 74 68 65 72 20 69 |seeing w|hether i|
|00001e00| 74 20 72 61 69 73 65 73 | 20 61 6e 20 65 78 63 65 |t raises| an exce|
|00001e10| 70 74 69 6f 6e 20 6f 72 | 20 6e 6f 74 2e 29 0a 5c |ption or| not.).\|
|00001e20| 65 6e 64 7b 66 75 6e 63 | 64 65 73 63 7d 0a 0a 5c |end{func|desc}..\|
|00001e30| 62 65 67 69 6e 7b 66 75 | 6e 63 64 65 73 63 7d 7b |begin{fu|ncdesc}{|
|00001e40| 68 61 73 68 7d 7b 6f 62 | 6a 65 63 74 7d 0a 20 20 |hash}{ob|ject}. |
|00001e50| 52 65 74 75 72 6e 20 74 | 68 65 20 68 61 73 68 20 |Return t|he hash |
|00001e60| 76 61 6c 75 65 20 6f 66 | 20 74 68 65 20 6f 62 6a |value of| the obj|
|00001e70| 65 63 74 20 28 69 66 20 | 69 74 20 68 61 73 20 6f |ect (if |it has o|
|00001e80| 6e 65 29 2e 20 20 48 61 | 73 68 20 76 61 6c 75 65 |ne). Ha|sh value|
|00001e90| 73 0a 20 20 61 72 65 20 | 33 32 2d 62 69 74 20 69 |s. are |32-bit i|
|00001ea0| 6e 74 65 67 65 72 73 2e | 20 20 54 68 65 79 20 61 |ntegers.| They a|
|00001eb0| 72 65 20 75 73 65 64 20 | 74 6f 20 71 75 69 63 6b |re used |to quick|
|00001ec0| 6c 79 20 63 6f 6d 70 61 | 72 65 20 64 69 63 74 69 |ly compa|re dicti|
|00001ed0| 6f 6e 61 72 79 0a 20 20 | 6b 65 79 73 20 64 75 72 |onary. |keys dur|
|00001ee0| 69 6e 67 20 61 20 64 69 | 63 74 69 6f 6e 61 72 79 |ing a di|ctionary|
|00001ef0| 20 6c 6f 6f 6b 75 70 2e | 20 20 4e 75 6d 65 72 69 | lookup.| Numeri|
|00001f00| 63 20 76 61 6c 75 65 73 | 20 74 68 61 74 20 63 6f |c values| that co|
|00001f10| 6d 70 61 72 65 20 65 71 | 75 61 6c 0a 20 20 68 61 |mpare eq|ual. ha|
|00001f20| 76 65 20 74 68 65 20 73 | 61 6d 65 20 68 61 73 68 |ve the s|ame hash|
|00001f30| 20 76 61 6c 75 65 20 28 | 65 76 65 6e 20 69 66 20 | value (|even if |
|00001f40| 74 68 65 79 20 61 72 65 | 20 6f 66 20 64 69 66 66 |they are| of diff|
|00001f50| 65 72 65 6e 74 20 74 79 | 70 65 73 2c 20 65 2e 67 |erent ty|pes, e.g|
|00001f60| 2e 0a 20 20 31 20 61 6e | 64 20 31 2e 30 29 2e 0a |.. 1 an|d 1.0)..|
|00001f70| 5c 65 6e 64 7b 66 75 6e | 63 64 65 73 63 7d 0a 0a |\end{fun|cdesc}..|
|00001f80| 5c 62 65 67 69 6e 7b 66 | 75 6e 63 64 65 73 63 7d |\begin{f|uncdesc}|
|00001f90| 7b 68 65 78 7d 7b 78 7d | 0a 20 20 43 6f 6e 76 65 |{hex}{x}|. Conve|
|00001fa0| 72 74 20 61 6e 20 69 6e | 74 65 67 65 72 20 6e 75 |rt an in|teger nu|
|00001fb0| 6d 62 65 72 20 28 6f 66 | 20 61 6e 79 20 73 69 7a |mber (of| any siz|
|00001fc0| 65 29 20 74 6f 20 61 20 | 68 65 78 61 64 65 63 69 |e) to a |hexadeci|
|00001fd0| 6d 61 6c 20 73 74 72 69 | 6e 67 2e 0a 20 20 54 68 |mal stri|ng.. Th|
|00001fe0| 65 20 72 65 73 75 6c 74 | 20 69 73 20 61 20 76 61 |e result| is a va|
|00001ff0| 6c 69 64 20 50 79 74 68 | 6f 6e 20 65 78 70 72 65 |lid Pyth|on expre|
|00002000| 73 73 69 6f 6e 2e 0a 5c | 65 6e 64 7b 66 75 6e 63 |ssion..\|end{func|
|00002010| 64 65 73 63 7d 0a 0a 5c | 62 65 67 69 6e 7b 66 75 |desc}..\|begin{fu|
|00002020| 6e 63 64 65 73 63 7d 7b | 69 64 7d 7b 6f 62 6a 65 |ncdesc}{|id}{obje|
|00002030| 63 74 7d 0a 20 20 52 65 | 74 75 72 6e 20 74 68 65 |ct}. Re|turn the|
|00002040| 20 60 69 64 65 6e 74 69 | 74 79 27 20 6f 66 20 61 | `identi|ty' of a|
|00002050| 6e 20 6f 62 6a 65 63 74 | 2e 20 20 54 68 69 73 20 |n object|. This |
|00002060| 69 73 20 61 6e 20 69 6e | 74 65 67 65 72 20 77 68 |is an in|teger wh|
|00002070| 69 63 68 20 69 73 0a 20 | 20 67 75 61 72 61 6e 74 |ich is. | guarant|
|00002080| 65 65 64 20 74 6f 20 62 | 65 20 75 6e 69 71 75 65 |eed to b|e unique|
|00002090| 20 61 6e 64 20 63 6f 6e | 73 74 61 6e 74 20 66 6f | and con|stant fo|
|000020a0| 72 20 74 68 69 73 20 6f | 62 6a 65 63 74 20 64 75 |r this o|bject du|
|000020b0| 72 69 6e 67 20 69 74 73 | 0a 20 20 6c 69 66 65 74 |ring its|. lifet|
|000020c0| 69 6d 65 2e 20 20 28 54 | 77 6f 20 6f 62 6a 65 63 |ime. (T|wo objec|
|000020d0| 74 73 20 77 68 6f 73 65 | 20 6c 69 66 65 74 69 6d |ts whose| lifetim|
|000020e0| 65 73 20 61 72 65 20 64 | 69 73 6a 75 6e 63 74 20 |es are d|isjunct |
|000020f0| 6d 61 79 20 68 61 76 65 | 20 74 68 65 0a 20 20 73 |may have| the. s|
|00002100| 61 6d 65 20 69 64 28 29 | 20 76 61 6c 75 65 2e 29 |ame id()| value.)|
|00002110| 20 20 28 49 6d 70 6c 65 | 6d 65 6e 74 61 74 69 6f | (Imple|mentatio|
|00002120| 6e 20 6e 6f 74 65 3a 20 | 74 68 69 73 20 69 73 20 |n note: |this is |
|00002130| 74 68 65 20 61 64 64 72 | 65 73 73 20 6f 66 20 74 |the addr|ess of t|
|00002140| 68 65 0a 20 20 6f 62 6a | 65 63 74 2e 29 0a 5c 65 |he. obj|ect.).\e|
|00002150| 6e 64 7b 66 75 6e 63 64 | 65 73 63 7d 0a 0a 5c 62 |nd{funcd|esc}..\b|
|00002160| 65 67 69 6e 7b 66 75 6e | 63 64 65 73 63 7d 7b 69 |egin{fun|cdesc}{i|
|00002170| 6e 70 75 74 7d 7b 5c 6f | 70 74 69 6f 6e 61 6c 7b |nput}{\o|ptional{|
|00002180| 70 72 6f 6d 70 74 7d 7d | 0a 20 20 41 6c 6d 6f 73 |prompt}}|. Almos|
|00002190| 74 20 65 71 75 69 76 61 | 6c 65 6e 74 20 74 6f 20 |t equiva|lent to |
|000021a0| 5c 63 6f 64 65 7b 65 76 | 61 6c 28 72 61 77 5f 69 |\code{ev|al(raw_i|
|000021b0| 6e 70 75 74 28 5c 76 61 | 72 7b 70 72 6f 6d 70 74 |nput(\va|r{prompt|
|000021c0| 7d 29 29 7d 2e 20 20 4c | 69 6b 65 0a 20 20 5c 63 |}))}. L|ike. \c|
|000021d0| 6f 64 65 7b 72 61 77 5f | 69 6e 70 75 74 28 29 7d |ode{raw_|input()}|
|000021e0| 2c 20 74 68 65 20 5c 76 | 61 72 7b 70 72 6f 6d 70 |, the \v|ar{promp|
|000021f0| 74 7d 20 61 72 67 75 6d | 65 6e 74 20 69 73 20 6f |t} argum|ent is o|
|00002200| 70 74 69 6f 6e 61 6c 2e | 20 20 54 68 65 20 64 69 |ptional.| The di|
|00002210| 66 66 65 72 65 6e 63 65 | 0a 20 20 69 73 20 74 68 |fference|. is th|
|00002220| 61 74 20 61 20 6c 6f 6e | 67 20 69 6e 70 75 74 20 |at a lon|g input |
|00002230| 65 78 70 72 65 73 73 69 | 6f 6e 20 6d 61 79 20 62 |expressi|on may b|
|00002240| 65 20 62 72 6f 6b 65 6e | 20 6f 76 65 72 20 6d 75 |e broken| over mu|
|00002250| 6c 74 69 70 6c 65 20 6c | 69 6e 65 73 20 75 73 69 |ltiple l|ines usi|
|00002260| 6e 67 0a 20 20 74 68 65 | 20 62 61 63 6b 73 6c 61 |ng. the| backsla|
|00002270| 73 68 20 63 6f 6e 76 65 | 6e 74 69 6f 6e 2e 0a 5c |sh conve|ntion..\|
|00002280| 65 6e 64 7b 66 75 6e 63 | 64 65 73 63 7d 0a 0a 5c |end{func|desc}..\|
|00002290| 62 65 67 69 6e 7b 66 75 | 6e 63 64 65 73 63 7d 7b |begin{fu|ncdesc}{|
|000022a0| 69 6e 74 7d 7b 78 7d 0a | 20 20 43 6f 6e 76 65 72 |int}{x}.| Conver|
|000022b0| 74 20 61 20 6e 75 6d 62 | 65 72 20 74 6f 20 61 20 |t a numb|er to a |
|000022c0| 70 6c 61 69 6e 20 69 6e | 74 65 67 65 72 2e 20 20 |plain in|teger. |
|000022d0| 54 68 65 20 61 72 67 75 | 6d 65 6e 74 20 6d 61 79 |The argu|ment may|
|000022e0| 20 62 65 20 61 20 70 6c | 61 69 6e 20 6f 72 0a 20 | be a pl|ain or. |
|000022f0| 20 6c 6f 6e 67 20 69 6e | 74 65 67 65 72 20 6f 72 | long in|teger or|
|00002300| 20 61 20 66 6c 6f 61 74 | 69 6e 67 20 70 6f 69 6e | a float|ing poin|
|00002310| 74 20 6e 75 6d 62 65 72 | 2e 20 20 43 6f 6e 76 65 |t number|. Conve|
|00002320| 72 73 69 6f 6e 20 6f 66 | 20 66 6c 6f 61 74 69 6e |rsion of| floatin|
|00002330| 67 0a 20 20 70 6f 69 6e | 74 20 6e 75 6d 62 65 72 |g. poin|t number|
|00002340| 73 20 74 6f 20 69 6e 74 | 65 67 65 72 73 20 69 73 |s to int|egers is|
|00002350| 20 64 65 66 69 6e 65 64 | 20 62 79 20 74 68 65 20 | defined| by the |
|00002360| 43 20 73 65 6d 61 6e 74 | 69 63 73 3b 20 6e 6f 72 |C semant|ics; nor|
|00002370| 6d 61 6c 6c 79 0a 20 20 | 74 68 65 20 63 6f 6e 76 |mally. |the conv|
|00002380| 65 72 73 69 6f 6e 20 74 | 72 75 6e 63 61 74 65 73 |ersion t|runcates|
|00002390| 20 74 6f 77 61 72 64 73 | 20 7a 65 72 6f 2e 5c 66 | towards| zero.\f|
|000023a0| 6f 6f 74 6e 6f 74 65 7b | 54 68 69 73 20 69 73 20 |ootnote{|This is |
|000023b0| 75 67 6c 79 20 2d 2d 2d | 20 74 68 65 0a 20 20 6c |ugly ---| the. l|
|000023c0| 61 6e 67 75 61 67 65 20 | 64 65 66 69 6e 69 74 69 |anguage |definiti|
|000023d0| 6f 6e 20 73 68 6f 75 6c | 64 20 72 65 71 75 69 72 |on shoul|d requir|
|000023e0| 65 20 74 72 75 6e 63 61 | 74 69 6f 6e 20 74 6f 77 |e trunca|tion tow|
|000023f0| 61 72 64 73 20 7a 65 72 | 6f 2e 7d 0a 5c 65 6e 64 |ards zer|o.}.\end|
|00002400| 7b 66 75 6e 63 64 65 73 | 63 7d 0a 0a 5c 62 65 67 |{funcdes|c}..\beg|
|00002410| 69 6e 7b 66 75 6e 63 64 | 65 73 63 7d 7b 6c 65 6e |in{funcd|esc}{len|
|00002420| 7d 7b 73 7d 0a 20 20 52 | 65 74 75 72 6e 20 74 68 |}{s}. R|eturn th|
|00002430| 65 20 6c 65 6e 67 74 68 | 20 28 74 68 65 20 6e 75 |e length| (the nu|
|00002440| 6d 62 65 72 20 6f 66 20 | 69 74 65 6d 73 29 20 6f |mber of |items) o|
|00002450| 66 20 61 6e 20 6f 62 6a | 65 63 74 2e 20 20 54 68 |f an obj|ect. Th|
|00002460| 65 20 61 72 67 75 6d 65 | 6e 74 0a 20 20 6d 61 79 |e argume|nt. may|
|00002470| 20 62 65 20 61 20 73 65 | 71 75 65 6e 63 65 20 28 | be a se|quence (|
|00002480| 73 74 72 69 6e 67 2c 20 | 74 75 70 6c 65 20 6f 72 |string, |tuple or|
|00002490| 20 6c 69 73 74 29 20 6f | 72 20 61 20 6d 61 70 70 | list) o|r a mapp|
|000024a0| 69 6e 67 20 28 64 69 63 | 74 69 6f 6e 61 72 79 29 |ing (dic|tionary)|
|000024b0| 2e 0a 5c 65 6e 64 7b 66 | 75 6e 63 64 65 73 63 7d |..\end{f|uncdesc}|
|000024c0| 0a 0a 5c 62 65 67 69 6e | 7b 66 75 6e 63 64 65 73 |..\begin|{funcdes|
|000024d0| 63 7d 7b 6c 6f 63 61 6c | 73 7d 7b 7d 0a 52 65 74 |c}{local|s}{}.Ret|
|000024e0| 75 72 6e 20 61 20 64 69 | 63 74 69 6f 6e 61 72 79 |urn a di|ctionary|
|000024f0| 20 72 65 70 72 65 73 65 | 6e 74 69 6e 67 20 74 68 | represe|nting th|
|00002500| 65 20 63 75 72 72 65 6e | 74 20 6c 6f 63 61 6c 20 |e curren|t local |
|00002510| 73 79 6d 62 6f 6c 20 74 | 61 62 6c 65 2e 0a 49 6e |symbol t|able..In|
|00002520| 73 69 64 65 20 61 20 66 | 75 6e 63 74 69 6f 6e 2c |side a f|unction,|
|00002530| 20 6d 6f 64 69 66 79 69 | 6e 67 20 74 68 69 73 20 | modifyi|ng this |
|00002540| 64 69 63 74 69 6f 6e 61 | 72 79 20 64 6f 65 73 20 |dictiona|ry does |
|00002550| 6e 6f 74 20 61 6c 77 61 | 79 73 20 68 61 76 65 20 |not alwa|ys have |
|00002560| 74 68 65 0a 64 65 73 69 | 72 65 64 20 65 66 66 65 |the.desi|red effe|
|00002570| 63 74 2e 0a 5c 65 6e 64 | 7b 66 75 6e 63 64 65 73 |ct..\end|{funcdes|
|00002580| 63 7d 0a 0a 5c 62 65 67 | 69 6e 7b 66 75 6e 63 64 |c}..\beg|in{funcd|
|00002590| 65 73 63 7d 7b 6c 6f 6e | 67 7d 7b 78 7d 0a 20 20 |esc}{lon|g}{x}. |
|000025a0| 43 6f 6e 76 65 72 74 20 | 61 20 6e 75 6d 62 65 72 |Convert |a number|
|000025b0| 20 74 6f 20 61 20 6c 6f | 6e 67 20 69 6e 74 65 67 | to a lo|ng integ|
|000025c0| 65 72 2e 20 20 54 68 65 | 20 61 72 67 75 6d 65 6e |er. The| argumen|
|000025d0| 74 20 6d 61 79 20 62 65 | 20 61 20 70 6c 61 69 6e |t may be| a plain|
|000025e0| 20 6f 72 0a 20 20 6c 6f | 6e 67 20 69 6e 74 65 67 | or. lo|ng integ|
|000025f0| 65 72 20 6f 72 20 61 20 | 66 6c 6f 61 74 69 6e 67 |er or a |floating|
|00002600| 20 70 6f 69 6e 74 20 6e | 75 6d 62 65 72 2e 0a 5c | point n|umber..\|
|00002610| 65 6e 64 7b 66 75 6e 63 | 64 65 73 63 7d 0a 0a 5c |end{func|desc}..\|
|00002620| 62 65 67 69 6e 7b 66 75 | 6e 63 64 65 73 63 7d 7b |begin{fu|ncdesc}{|
|00002630| 6d 61 70 7d 7b 66 75 6e | 63 74 69 6f 6e 5c 2c 20 |map}{fun|ction\, |
|00002640| 6c 69 73 74 5c 2c 20 2e | 2e 2e 7d 0a 41 70 70 6c |list\, .|..}.Appl|
|00002650| 79 20 5c 76 61 72 7b 66 | 75 6e 63 74 69 6f 6e 7d |y \var{f|unction}|
|00002660| 20 74 6f 20 65 76 65 72 | 79 20 69 74 65 6d 20 6f | to ever|y item o|
|00002670| 66 20 5c 76 61 72 7b 6c | 69 73 74 7d 20 61 6e 64 |f \var{l|ist} and|
|00002680| 20 72 65 74 75 72 6e 20 | 61 20 6c 69 73 74 0a 6f | return |a list.o|
|00002690| 66 20 74 68 65 20 72 65 | 73 75 6c 74 73 2e 20 20 |f the re|sults. |
|000026a0| 49 66 20 61 64 64 69 74 | 69 6f 6e 61 6c 20 5c 76 |If addit|ional \v|
|000026b0| 61 72 7b 6c 69 73 74 7d | 20 61 72 67 75 6d 65 6e |ar{list}| argumen|
|000026c0| 74 73 20 61 72 65 20 70 | 61 73 73 65 64 2c 20 0a |ts are p|assed, .|
|000026d0| 5c 76 61 72 7b 66 75 6e | 63 74 69 6f 6e 7d 20 6d |\var{fun|ction} m|
|000026e0| 75 73 74 20 74 61 6b 65 | 20 74 68 61 74 20 6d 61 |ust take| that ma|
|000026f0| 6e 79 20 61 72 67 75 6d | 65 6e 74 73 20 61 6e 64 |ny argum|ents and|
|00002700| 20 69 73 20 61 70 70 6c | 69 65 64 20 74 6f 0a 74 | is appl|ied to.t|
|00002710| 68 65 20 69 74 65 6d 73 | 20 6f 66 20 61 6c 6c 20 |he items| of all |
|00002720| 6c 69 73 74 73 20 69 6e | 20 70 61 72 61 6c 6c 65 |lists in| paralle|
|00002730| 6c 3b 20 69 66 20 61 20 | 6c 69 73 74 20 69 73 20 |l; if a |list is |
|00002740| 73 68 6f 72 74 65 72 20 | 74 68 61 6e 20 61 6e 6f |shorter |than ano|
|00002750| 74 68 65 72 0a 69 74 20 | 69 73 20 61 73 73 75 6d |ther.it |is assum|
|00002760| 65 64 20 74 6f 20 62 65 | 20 65 78 74 65 6e 64 65 |ed to be| extende|
|00002770| 64 20 77 69 74 68 20 5c | 63 6f 64 65 7b 4e 6f 6e |d with \|code{Non|
|00002780| 65 7d 20 69 74 65 6d 73 | 2e 20 20 49 66 0a 5c 76 |e} items|. If.\v|
|00002790| 61 72 7b 66 75 6e 63 74 | 69 6f 6e 7d 20 69 73 20 |ar{funct|ion} is |
|000027a0| 5c 63 6f 64 65 7b 4e 6f | 6e 65 7d 2c 20 74 68 65 |\code{No|ne}, the|
|000027b0| 20 69 64 65 6e 74 69 74 | 79 20 66 75 6e 63 74 69 | identit|y functi|
|000027c0| 6f 6e 20 69 73 20 61 73 | 73 75 6d 65 64 3b 20 69 |on is as|sumed; i|
|000027d0| 66 0a 74 68 65 72 65 20 | 61 72 65 20 6d 75 6c 74 |f.there |are mult|
|000027e0| 69 70 6c 65 20 6c 69 73 | 74 20 61 72 67 75 6d 65 |iple lis|t argume|
|000027f0| 6e 74 73 2c 20 5c 63 6f | 64 65 7b 6d 61 70 7d 20 |nts, \co|de{map} |
|00002800| 72 65 74 75 72 6e 73 20 | 61 20 6c 69 73 74 0a 63 |returns |a list.c|
|00002810| 6f 6e 73 69 73 74 69 6e | 67 20 6f 66 20 74 75 70 |onsistin|g of tup|
|00002820| 6c 65 73 20 63 6f 6e 74 | 61 69 6e 69 6e 67 20 74 |les cont|aining t|
|00002830| 68 65 20 63 6f 72 72 65 | 73 70 6f 6e 64 69 6e 67 |he corre|sponding|
|00002840| 20 69 74 65 6d 73 20 66 | 72 6f 6d 20 61 6c 6c 20 | items f|rom all |
|00002850| 6c 69 73 74 73 0a 28 69 | 2e 65 2e 20 61 20 6b 69 |lists.(i|.e. a ki|
|00002860| 6e 64 20 6f 66 20 74 72 | 61 6e 73 70 6f 73 65 20 |nd of tr|anspose |
|00002870| 6f 70 65 72 61 74 69 6f | 6e 29 2e 20 20 54 68 65 |operatio|n). The|
|00002880| 20 5c 76 61 72 7b 6c 69 | 73 74 7d 20 61 72 67 75 | \var{li|st} argu|
|00002890| 6d 65 6e 74 73 20 6d 61 | 79 20 62 65 0a 61 6e 79 |ments ma|y be.any|
|000028a0| 20 6b 69 6e 64 20 6f 66 | 20 73 65 71 75 65 6e 63 | kind of| sequenc|
|000028b0| 65 3b 20 74 68 65 20 72 | 65 73 75 6c 74 20 69 73 |e; the r|esult is|
|000028c0| 20 61 6c 77 61 79 73 20 | 61 20 6c 69 73 74 2e 0a | always |a list..|
|000028d0| 5c 65 6e 64 7b 66 75 6e | 63 64 65 73 63 7d 0a 0a |\end{fun|cdesc}..|
|000028e0| 5c 62 65 67 69 6e 7b 66 | 75 6e 63 64 65 73 63 7d |\begin{f|uncdesc}|
|000028f0| 7b 6d 61 78 7d 7b 73 7d | 0a 20 20 52 65 74 75 72 |{max}{s}|. Retur|
|00002900| 6e 20 74 68 65 20 6c 61 | 72 67 65 73 74 20 69 74 |n the la|rgest it|
|00002910| 65 6d 20 6f 66 20 61 20 | 6e 6f 6e 2d 65 6d 70 74 |em of a |non-empt|
|00002920| 79 20 73 65 71 75 65 6e | 63 65 20 28 73 74 72 69 |y sequen|ce (stri|
|00002930| 6e 67 2c 20 74 75 70 6c | 65 20 6f 72 0a 20 20 6c |ng, tupl|e or. l|
|00002940| 69 73 74 29 2e 0a 5c 65 | 6e 64 7b 66 75 6e 63 64 |ist)..\e|nd{funcd|
|00002950| 65 73 63 7d 0a 0a 5c 62 | 65 67 69 6e 7b 66 75 6e |esc}..\b|egin{fun|
|00002960| 63 64 65 73 63 7d 7b 6d | 69 6e 7d 7b 73 7d 0a 20 |cdesc}{m|in}{s}. |
|00002970| 20 52 65 74 75 72 6e 20 | 74 68 65 20 73 6d 61 6c | Return |the smal|
|00002980| 6c 65 73 74 20 69 74 65 | 6d 20 6f 66 20 61 20 6e |lest ite|m of a n|
|00002990| 6f 6e 2d 65 6d 70 74 79 | 20 73 65 71 75 65 6e 63 |on-empty| sequenc|
|000029a0| 65 20 28 73 74 72 69 6e | 67 2c 20 74 75 70 6c 65 |e (strin|g, tuple|
|000029b0| 20 6f 72 0a 20 20 6c 69 | 73 74 29 2e 0a 5c 65 6e | or. li|st)..\en|
|000029c0| 64 7b 66 75 6e 63 64 65 | 73 63 7d 0a 0a 5c 62 65 |d{funcde|sc}..\be|
|000029d0| 67 69 6e 7b 66 75 6e 63 | 64 65 73 63 7d 7b 6f 63 |gin{func|desc}{oc|
|000029e0| 74 7d 7b 78 7d 0a 20 20 | 43 6f 6e 76 65 72 74 20 |t}{x}. |Convert |
|000029f0| 61 6e 20 69 6e 74 65 67 | 65 72 20 6e 75 6d 62 65 |an integ|er numbe|
|00002a00| 72 20 28 6f 66 20 61 6e | 79 20 73 69 7a 65 29 20 |r (of an|y size) |
|00002a10| 74 6f 20 61 6e 20 6f 63 | 74 61 6c 20 73 74 72 69 |to an oc|tal stri|
|00002a20| 6e 67 2e 20 20 54 68 65 | 0a 20 20 72 65 73 75 6c |ng. The|. resul|
|00002a30| 74 20 69 73 20 61 20 76 | 61 6c 69 64 20 50 79 74 |t is a v|alid Pyt|
|00002a40| 68 6f 6e 20 65 78 70 72 | 65 73 73 69 6f 6e 2e 0a |hon expr|ession..|
|00002a50| 5c 65 6e 64 7b 66 75 6e | 63 64 65 73 63 7d 0a 0a |\end{fun|cdesc}..|
|00002a60| 5c 62 65 67 69 6e 7b 66 | 75 6e 63 64 65 73 63 7d |\begin{f|uncdesc}|
|00002a70| 7b 6f 70 65 6e 7d 7b 66 | 69 6c 65 6e 61 6d 65 5c |{open}{f|ilename\|
|00002a80| 6f 70 74 69 6f 6e 61 6c | 7b 5c 2c 20 6d 6f 64 65 |optional|{\, mode|
|00002a90| 5c 6f 70 74 69 6f 6e 61 | 6c 7b 5c 2c 20 62 75 66 |\optiona|l{\, buf|
|00002aa0| 73 69 7a 65 7d 7d 7d 0a | 20 20 52 65 74 75 72 6e |size}}}.| Return|
|00002ab0| 20 61 20 6e 65 77 20 66 | 69 6c 65 20 6f 62 6a 65 | a new f|ile obje|
|00002ac0| 63 74 20 28 64 65 73 63 | 72 69 62 65 64 20 65 61 |ct (desc|ribed ea|
|00002ad0| 72 6c 69 65 72 20 75 6e | 64 65 72 20 42 75 69 6c |rlier un|der Buil|
|00002ae0| 74 2d 69 6e 20 54 79 70 | 65 73 29 2e 0a 20 20 54 |t-in Typ|es).. T|
|00002af0| 68 65 20 66 69 72 73 74 | 20 74 77 6f 20 61 72 67 |he first| two arg|
|00002b00| 75 6d 65 6e 74 73 20 61 | 72 65 20 74 68 65 20 73 |uments a|re the s|
|00002b10| 61 6d 65 20 61 73 20 66 | 6f 72 20 5c 63 6f 64 65 |ame as f|or \code|
|00002b20| 7b 73 74 64 69 6f 7d 27 | 73 0a 20 20 5c 63 6f 64 |{stdio}'|s. \cod|
|00002b30| 65 7b 66 6f 70 65 6e 28 | 29 7d 3a 20 5c 76 61 72 |e{fopen(|)}: \var|
|00002b40| 7b 66 69 6c 65 6e 61 6d | 65 7d 20 69 73 20 74 68 |{filenam|e} is th|
|00002b50| 65 20 66 69 6c 65 20 6e | 61 6d 65 20 74 6f 20 62 |e file n|ame to b|
|00002b60| 65 20 6f 70 65 6e 65 64 | 2c 0a 20 20 5c 76 61 72 |e opened|,. \var|
|00002b70| 7b 6d 6f 64 65 7d 20 69 | 6e 64 69 63 61 74 65 73 |{mode} i|ndicates|
|00002b80| 20 68 6f 77 20 74 68 65 | 20 66 69 6c 65 20 69 73 | how the| file is|
|00002b90| 20 74 6f 20 62 65 20 6f | 70 65 6e 65 64 3a 20 5c | to be o|pened: \|
|00002ba0| 63 6f 64 65 7b 27 72 27 | 7d 20 66 6f 72 0a 20 20 |code{'r'|} for. |
|00002bb0| 72 65 61 64 69 6e 67 2c | 20 5c 63 6f 64 65 7b 27 |reading,| \code{'|
|00002bc0| 77 27 7d 20 66 6f 72 20 | 77 72 69 74 69 6e 67 20 |w'} for |writing |
|00002bd0| 28 74 72 75 6e 63 61 74 | 69 6e 67 20 61 6e 20 65 |(truncat|ing an e|
|00002be0| 78 69 73 74 69 6e 67 20 | 66 69 6c 65 29 2c 20 61 |xisting |file), a|
|00002bf0| 6e 64 0a 20 20 5c 63 6f | 64 65 7b 27 61 27 7d 20 |nd. \co|de{'a'} |
|00002c00| 6f 70 65 6e 73 20 69 74 | 20 66 6f 72 20 61 70 70 |opens it| for app|
|00002c10| 65 6e 64 69 6e 67 20 28 | 77 68 69 63 68 20 6f 6e |ending (|which on|
|00002c20| 20 7b 5c 65 6d 20 73 6f | 6d 65 7d 20 5c 55 4e 49 | {\em so|me} \UNI|
|00002c30| 58 7b 7d 0a 20 20 73 79 | 73 74 65 6d 73 20 6d 65 |X{}. sy|stems me|
|00002c40| 61 6e 73 20 74 68 61 74 | 20 7b 5c 65 6d 20 61 6c |ans that| {\em al|
|00002c50| 6c 7d 20 77 72 69 74 65 | 73 20 61 70 70 65 6e 64 |l} write|s append|
|00002c60| 20 74 6f 20 74 68 65 20 | 65 6e 64 20 6f 66 20 74 | to the |end of t|
|00002c70| 68 65 20 66 69 6c 65 2c | 0a 20 20 72 65 67 61 72 |he file,|. regar|
|00002c80| 64 6c 65 73 73 20 6f 66 | 20 74 68 65 20 63 75 72 |dless of| the cur|
|00002c90| 72 65 6e 74 20 73 65 65 | 6b 20 70 6f 73 69 74 69 |rent see|k positi|
|00002ca0| 6f 6e 29 2e 0a 20 20 4d | 6f 64 65 73 20 5c 63 6f |on).. M|odes \co|
|00002cb0| 64 65 7b 27 72 2b 27 7d | 2c 20 5c 63 6f 64 65 7b |de{'r+'}|, \code{|
|00002cc0| 27 77 2b 27 7d 20 61 6e | 64 0a 20 20 5c 63 6f 64 |'w+'} an|d. \cod|
|00002cd0| 65 7b 27 61 2b 27 7d 20 | 6f 70 65 6e 20 74 68 65 |e{'a+'} |open the|
|00002ce0| 20 66 69 6c 65 20 66 6f | 72 20 75 70 64 61 74 69 | file fo|r updati|
|00002cf0| 6e 67 2c 20 70 72 6f 76 | 69 64 65 64 20 74 68 65 |ng, prov|ided the|
|00002d00| 20 75 6e 64 65 72 6c 79 | 69 6e 67 0a 20 20 5c 63 | underly|ing. \c|
|00002d10| 6f 64 65 7b 73 74 64 69 | 6f 7d 20 6c 69 62 72 61 |ode{stdi|o} libra|
|00002d20| 72 79 20 75 6e 64 65 72 | 73 74 61 6e 64 73 20 74 |ry under|stands t|
|00002d30| 68 69 73 2e 20 20 4f 6e | 20 73 79 73 74 65 6d 73 |his. On| systems|
|00002d40| 20 74 68 61 74 20 64 69 | 66 66 65 72 65 6e 74 69 | that di|fferenti|
|00002d50| 61 74 65 0a 20 20 62 65 | 74 77 65 65 6e 20 62 69 |ate. be|tween bi|
|00002d60| 6e 61 72 79 20 61 6e 64 | 20 74 65 78 74 20 66 69 |nary and| text fi|
|00002d70| 6c 65 73 2c 20 5c 63 6f | 64 65 7b 27 62 27 7d 20 |les, \co|de{'b'} |
|00002d80| 61 70 70 65 6e 64 65 64 | 20 74 6f 20 74 68 65 20 |appended| to the |
|00002d90| 6d 6f 64 65 20 6f 70 65 | 6e 73 0a 20 20 74 68 65 |mode ope|ns. the|
|00002da0| 20 66 69 6c 65 20 69 6e | 20 62 69 6e 61 72 79 20 | file in| binary |
|00002db0| 6d 6f 64 65 2e 20 20 49 | 66 20 74 68 65 20 66 69 |mode. I|f the fi|
|00002dc0| 6c 65 20 63 61 6e 6e 6f | 74 20 62 65 20 6f 70 65 |le canno|t be ope|
|00002dd0| 6e 65 64 2c 20 5c 63 6f | 64 65 7b 49 4f 45 72 72 |ned, \co|de{IOErr|
|00002de0| 6f 72 7d 0a 20 20 69 73 | 20 72 61 69 73 65 64 2e |or}. is| raised.|
|00002df0| 0a 49 66 20 5c 76 61 72 | 7b 6d 6f 64 65 7d 20 69 |.If \var|{mode} i|
|00002e00| 73 20 6f 6d 69 74 74 65 | 64 2c 20 69 74 20 64 65 |s omitte|d, it de|
|00002e10| 66 61 75 6c 74 73 20 74 | 6f 20 5c 63 6f 64 65 7b |faults t|o \code{|
|00002e20| 27 72 27 7d 2e 0a 54 68 | 65 20 6f 70 74 69 6f 6e |'r'}..Th|e option|
|00002e30| 61 6c 20 5c 76 61 72 7b | 62 75 66 73 69 7a 65 7d |al \var{|bufsize}|
|00002e40| 20 61 72 67 75 6d 65 6e | 74 20 73 70 65 63 69 66 | argumen|t specif|
|00002e50| 69 65 73 20 74 68 65 20 | 66 69 6c 65 27 73 20 64 |ies the |file's d|
|00002e60| 65 73 69 72 65 64 0a 62 | 75 66 66 65 72 20 73 69 |esired.b|uffer si|
|00002e70| 7a 65 3a 20 30 20 6d 65 | 61 6e 73 20 75 6e 62 75 |ze: 0 me|ans unbu|
|00002e80| 66 66 65 72 65 64 2c 20 | 31 20 6d 65 61 6e 73 20 |ffered, |1 means |
|00002e90| 6c 69 6e 65 20 62 75 66 | 66 65 72 65 64 2c 20 61 |line buf|fered, a|
|00002ea0| 6e 79 20 6f 74 68 65 72 | 0a 70 6f 73 69 74 69 76 |ny other|.positiv|
|00002eb0| 65 20 76 61 6c 75 65 20 | 6d 65 61 6e 73 20 75 73 |e value |means us|
|00002ec0| 65 20 61 20 62 75 66 66 | 65 72 20 6f 66 20 28 61 |e a buff|er of (a|
|00002ed0| 70 70 72 6f 78 69 6d 61 | 74 65 6c 79 29 20 74 68 |pproxima|tely) th|
|00002ee0| 61 74 20 73 69 7a 65 2e | 20 20 41 0a 6e 65 67 61 |at size.| A.nega|
|00002ef0| 74 69 76 65 20 5c 76 61 | 72 7b 62 75 66 73 69 7a |tive \va|r{bufsiz|
|00002f00| 65 7d 20 6d 65 61 6e 73 | 20 74 6f 20 75 73 65 20 |e} means| to use |
|00002f10| 74 68 65 20 73 79 73 74 | 65 6d 20 64 65 66 61 75 |the syst|em defau|
|00002f20| 6c 74 2c 20 77 68 69 63 | 68 20 69 73 0a 75 73 75 |lt, whic|h is.usu|
|00002f30| 61 6c 6c 79 20 6c 69 6e | 65 20 62 75 66 66 65 72 |ally lin|e buffer|
|00002f40| 65 64 20 66 6f 72 20 66 | 6f 72 20 74 74 79 20 64 |ed for f|or tty d|
|00002f50| 65 76 69 63 65 73 20 61 | 6e 64 20 66 75 6c 6c 79 |evices a|nd fully|
|00002f60| 20 62 75 66 66 65 72 65 | 64 20 66 6f 72 20 6f 74 | buffere|d for ot|
|00002f70| 68 65 72 0a 66 69 6c 65 | 73 2e 25 0a 5c 66 6f 6f |her.file|s.%.\foo|
|00002f80| 74 6e 6f 74 65 7b 53 70 | 65 63 69 66 79 69 6e 67 |tnote{Sp|ecifying|
|00002f90| 20 61 20 62 75 66 66 65 | 72 20 73 69 7a 65 20 63 | a buffe|r size c|
|00002fa0| 75 72 72 65 6e 74 6c 79 | 20 68 61 73 20 6e 6f 20 |urrently| has no |
|00002fb0| 65 66 66 65 63 74 20 6f | 6e 20 73 79 73 74 65 6d |effect o|n system|
|00002fc0| 73 0a 74 68 61 74 20 64 | 6f 6e 27 74 20 68 61 76 |s.that d|on't hav|
|00002fd0| 65 20 5c 63 6f 64 65 7b | 73 65 74 76 62 75 66 28 |e \code{|setvbuf(|
|00002fe0| 29 7d 2e 20 20 54 68 65 | 20 69 6e 74 65 72 66 61 |)}. The| interfa|
|00002ff0| 63 65 20 74 6f 20 73 70 | 65 63 69 66 79 20 74 68 |ce to sp|ecify th|
|00003000| 65 20 62 75 66 66 65 72 | 0a 73 69 7a 65 20 69 73 |e buffer|.size is|
|00003010| 20 6e 6f 74 20 64 6f 6e | 65 20 75 73 69 6e 67 20 | not don|e using |
|00003020| 61 20 6d 65 74 68 6f 64 | 20 74 68 61 74 20 63 61 |a method| that ca|
|00003030| 6c 6c 73 20 5c 63 6f 64 | 65 7b 73 65 74 76 62 75 |lls \cod|e{setvbu|
|00003040| 66 28 29 7d 2c 20 62 65 | 63 61 75 73 65 0a 74 68 |f()}, be|cause.th|
|00003050| 61 74 20 6d 61 79 20 64 | 75 6d 70 20 63 6f 72 65 |at may d|ump core|
|00003060| 20 77 68 65 6e 20 63 61 | 6c 6c 65 64 20 61 66 74 | when ca|lled aft|
|00003070| 65 72 20 61 6e 79 20 49 | 2f 4f 20 68 61 73 20 62 |er any I|/O has b|
|00003080| 65 65 6e 20 70 65 72 66 | 6f 72 6d 65 64 2c 20 61 |een perf|ormed, a|
|00003090| 6e 64 0a 74 68 65 72 65 | 27 73 20 6e 6f 20 72 65 |nd.there|'s no re|
|000030a0| 6c 69 61 62 6c 65 20 77 | 61 79 20 74 6f 20 64 65 |liable w|ay to de|
|000030b0| 74 65 72 6d 69 6e 65 20 | 77 68 65 74 68 65 72 20 |termine |whether |
|000030c0| 74 68 69 73 20 69 73 20 | 74 68 65 20 63 61 73 65 |this is |the case|
|000030d0| 2e 7d 0a 5c 65 6e 64 7b | 66 75 6e 63 64 65 73 63 |.}.\end{|funcdesc|
|000030e0| 7d 0a 0a 5c 62 65 67 69 | 6e 7b 66 75 6e 63 64 65 |}..\begi|n{funcde|
|000030f0| 73 63 7d 7b 6f 72 64 7d | 7b 63 7d 0a 20 20 52 65 |sc}{ord}|{c}. Re|
|00003100| 74 75 72 6e 20 74 68 65 | 20 5c 41 53 43 49 49 7b |turn the| \ASCII{|
|00003110| 7d 20 76 61 6c 75 65 20 | 6f 66 20 61 20 73 74 72 |} value |of a str|
|00003120| 69 6e 67 20 6f 66 20 6f | 6e 65 20 63 68 61 72 61 |ing of o|ne chara|
|00003130| 63 74 65 72 2e 20 20 45 | 2e 67 2e 2c 0a 20 20 5c |cter. E|.g.,. \|
|00003140| 63 6f 64 65 7b 6f 72 64 | 28 27 61 27 29 7d 20 72 |code{ord|('a')} r|
|00003150| 65 74 75 72 6e 73 20 74 | 68 65 20 69 6e 74 65 67 |eturns t|he integ|
|00003160| 65 72 20 5c 63 6f 64 65 | 7b 39 37 7d 2e 20 20 54 |er \code|{97}. T|
|00003170| 68 69 73 20 69 73 20 74 | 68 65 20 69 6e 76 65 72 |his is t|he inver|
|00003180| 73 65 20 6f 66 0a 20 20 | 5c 63 6f 64 65 7b 63 68 |se of. |\code{ch|
|00003190| 72 28 29 7d 2e 0a 5c 65 | 6e 64 7b 66 75 6e 63 64 |r()}..\e|nd{funcd|
|000031a0| 65 73 63 7d 0a 0a 5c 62 | 65 67 69 6e 7b 66 75 6e |esc}..\b|egin{fun|
|000031b0| 63 64 65 73 63 7d 7b 70 | 6f 77 7d 7b 78 5c 2c 20 |cdesc}{p|ow}{x\, |
|000031c0| 79 5c 6f 70 74 69 6f 6e | 61 6c 7b 5c 2c 20 7a 7d |y\option|al{\, z}|
|000031d0| 7d 0a 20 20 52 65 74 75 | 72 6e 20 5c 76 61 72 7b |}. Retu|rn \var{|
|000031e0| 78 7d 20 74 6f 20 74 68 | 65 20 70 6f 77 65 72 20 |x} to th|e power |
|000031f0| 5c 76 61 72 7b 79 7d 3b | 20 69 66 20 5c 76 61 72 |\var{y};| if \var|
|00003200| 7b 7a 7d 20 69 73 20 70 | 72 65 73 65 6e 74 2c 20 |{z} is p|resent, |
|00003210| 72 65 74 75 72 6e 0a 20 | 20 5c 76 61 72 7b 78 7d |return. | \var{x}|
|00003220| 20 74 6f 20 74 68 65 20 | 70 6f 77 65 72 20 5c 76 | to the |power \v|
|00003230| 61 72 7b 79 7d 2c 20 6d | 6f 64 75 6c 6f 20 5c 76 |ar{y}, m|odulo \v|
|00003240| 61 72 7b 7a 7d 20 28 63 | 6f 6d 70 75 74 65 64 20 |ar{z} (c|omputed |
|00003250| 6d 6f 72 65 0a 20 20 65 | 66 66 69 63 69 65 6e 74 |more. e|fficient|
|00003260| 6c 79 20 74 68 61 6e 20 | 5c 63 6f 64 65 7b 70 6f |ly than |\code{po|
|00003270| 77 28 5c 76 61 72 7b 78 | 7d 2c 20 5c 76 61 72 7b |w(\var{x|}, \var{|
|00003280| 79 7d 29 20 5c 25 20 5c | 76 61 72 7b 7a 7d 7d 29 |y}) \% \|var{z}})|
|00003290| 2e 0a 20 20 54 68 65 20 | 61 72 67 75 6d 65 6e 74 |.. The |argument|
|000032a0| 73 20 6d 75 73 74 20 68 | 61 76 65 0a 20 20 6e 75 |s must h|ave. nu|
|000032b0| 6d 65 72 69 63 20 74 79 | 70 65 73 2e 20 20 57 69 |meric ty|pes. Wi|
|000032c0| 74 68 20 6d 69 78 65 64 | 20 6f 70 65 72 61 6e 64 |th mixed| operand|
|000032d0| 20 74 79 70 65 73 2c 20 | 74 68 65 20 72 75 6c 65 | types, |the rule|
|000032e0| 73 20 66 6f 72 20 62 69 | 6e 61 72 79 0a 20 20 61 |s for bi|nary. a|
|000032f0| 72 69 74 68 6d 65 74 69 | 63 20 6f 70 65 72 61 74 |rithmeti|c operat|
|00003300| 6f 72 73 20 61 70 70 6c | 79 2e 20 20 54 68 65 20 |ors appl|y. The |
|00003310| 65 66 66 65 63 74 69 76 | 65 20 6f 70 65 72 61 6e |effectiv|e operan|
|00003320| 64 20 74 79 70 65 20 69 | 73 20 61 6c 73 6f 20 74 |d type i|s also t|
|00003330| 68 65 0a 20 20 74 79 70 | 65 20 6f 66 20 74 68 65 |he. typ|e of the|
|00003340| 20 72 65 73 75 6c 74 3b | 20 69 66 20 74 68 65 20 | result;| if the |
|00003350| 72 65 73 75 6c 74 20 69 | 73 20 6e 6f 74 20 65 78 |result i|s not ex|
|00003360| 70 72 65 73 73 69 62 6c | 65 20 69 6e 20 74 68 69 |pressibl|e in thi|
|00003370| 73 20 74 79 70 65 2c 20 | 74 68 65 0a 20 20 66 75 |s type, |the. fu|
|00003380| 6e 63 74 69 6f 6e 20 72 | 61 69 73 65 73 20 61 6e |nction r|aises an|
|00003390| 20 65 78 63 65 70 74 69 | 6f 6e 3b 20 65 2e 67 2e | excepti|on; e.g.|
|000033a0| 2c 20 5c 63 6f 64 65 7b | 70 6f 77 28 32 2c 20 2d |, \code{|pow(2, -|
|000033b0| 31 29 7d 20 6f 72 20 5c | 63 6f 64 65 7b 70 6f 77 |1)} or \|code{pow|
|000033c0| 28 32 2c 0a 20 20 33 35 | 30 30 30 29 7d 20 69 73 |(2,. 35|000)} is|
|000033d0| 20 6e 6f 74 20 61 6c 6c | 6f 77 65 64 2e 0a 5c 65 | not all|owed..\e|
|000033e0| 6e 64 7b 66 75 6e 63 64 | 65 73 63 7d 0a 0a 5c 62 |nd{funcd|esc}..\b|
|000033f0| 65 67 69 6e 7b 66 75 6e | 63 64 65 73 63 7d 7b 72 |egin{fun|cdesc}{r|
|00003400| 61 6e 67 65 7d 7b 5c 6f | 70 74 69 6f 6e 61 6c 7b |ange}{\o|ptional{|
|00003410| 73 74 61 72 74 5c 2c 7d | 20 65 6e 64 5c 6f 70 74 |start\,}| end\opt|
|00003420| 69 6f 6e 61 6c 7b 5c 2c | 20 73 74 65 70 7d 7d 0a |ional{\,| step}}.|
|00003430| 20 20 54 68 69 73 20 69 | 73 20 61 20 76 65 72 73 | This i|s a vers|
|00003440| 61 74 69 6c 65 20 66 75 | 6e 63 74 69 6f 6e 20 74 |atile fu|nction t|
|00003450| 6f 20 63 72 65 61 74 65 | 20 6c 69 73 74 73 20 63 |o create| lists c|
|00003460| 6f 6e 74 61 69 6e 69 6e | 67 20 61 72 69 74 68 6d |ontainin|g arithm|
|00003470| 65 74 69 63 0a 20 20 70 | 72 6f 67 72 65 73 73 69 |etic. p|rogressi|
|00003480| 6f 6e 73 2e 20 20 49 74 | 20 69 73 20 6d 6f 73 74 |ons. It| is most|
|00003490| 20 6f 66 74 65 6e 20 75 | 73 65 64 20 69 6e 20 5c | often u|sed in \|
|000034a0| 63 6f 64 65 7b 66 6f 72 | 7d 20 6c 6f 6f 70 73 2e |code{for|} loops.|
|000034b0| 20 20 54 68 65 0a 20 20 | 61 72 67 75 6d 65 6e 74 | The. |argument|
|000034c0| 73 20 6d 75 73 74 20 62 | 65 20 70 6c 61 69 6e 20 |s must b|e plain |
|000034d0| 69 6e 74 65 67 65 72 73 | 2e 20 20 49 66 20 74 68 |integers|. If th|
|000034e0| 65 20 5c 76 61 72 7b 73 | 74 65 70 7d 20 61 72 67 |e \var{s|tep} arg|
|000034f0| 75 6d 65 6e 74 20 69 73 | 0a 20 20 6f 6d 69 74 74 |ument is|. omitt|
|00003500| 65 64 2c 20 69 74 20 64 | 65 66 61 75 6c 74 73 20 |ed, it d|efaults |
|00003510| 74 6f 20 5c 63 6f 64 65 | 7b 31 7d 2e 20 20 49 66 |to \code|{1}. If|
|00003520| 20 74 68 65 20 5c 76 61 | 72 7b 73 74 61 72 74 7d | the \va|r{start}|
|00003530| 20 61 72 67 75 6d 65 6e | 74 20 69 73 0a 20 20 6f | argumen|t is. o|
|00003540| 6d 69 74 74 65 64 2c 20 | 69 74 20 64 65 66 61 75 |mitted, |it defau|
|00003550| 6c 74 73 20 74 6f 20 5c | 63 6f 64 65 7b 30 7d 2e |lts to \|code{0}.|
|00003560| 20 20 54 68 65 20 66 75 | 6c 6c 20 66 6f 72 6d 20 | The fu|ll form |
|00003570| 72 65 74 75 72 6e 73 20 | 61 20 6c 69 73 74 20 6f |returns |a list o|
|00003580| 66 0a 20 20 70 6c 61 69 | 6e 20 69 6e 74 65 67 65 |f. plai|n intege|
|00003590| 72 73 20 5c 63 6f 64 65 | 7b 5b 5c 76 61 72 7b 73 |rs \code|{[\var{s|
|000035a0| 74 61 72 74 7d 2c 20 5c | 76 61 72 7b 73 74 61 72 |tart}, \|var{star|
|000035b0| 74 7d 20 2b 20 5c 76 61 | 72 7b 73 74 65 70 7d 2c |t} + \va|r{step},|
|000035c0| 0a 20 20 5c 76 61 72 7b | 73 74 61 72 74 7d 20 2b |. \var{|start} +|
|000035d0| 20 32 20 2a 20 5c 76 61 | 72 7b 73 74 65 70 7d 2c | 2 * \va|r{step},|
|000035e0| 20 5c 6c 64 6f 74 73 5d | 7d 2e 20 20 49 66 20 5c | \ldots]|}. If \|
|000035f0| 76 61 72 7b 73 74 65 70 | 7d 20 69 73 20 70 6f 73 |var{step|} is pos|
|00003600| 69 74 69 76 65 2c 0a 20 | 20 74 68 65 20 6c 61 73 |itive,. | the las|
|00003610| 74 20 65 6c 65 6d 65 6e | 74 20 69 73 20 74 68 65 |t elemen|t is the|
|00003620| 20 6c 61 72 67 65 73 74 | 20 5c 63 6f 64 65 7b 5c | largest| \code{\|
|00003630| 76 61 72 7b 73 74 61 72 | 74 7d 20 2b 20 5c 76 61 |var{star|t} + \va|
|00003640| 72 7b 69 7d 20 2a 0a 20 | 20 5c 76 61 72 7b 73 74 |r{i} *. | \var{st|
|00003650| 65 70 7d 7d 20 6c 65 73 | 73 20 74 68 61 6e 20 5c |ep}} les|s than \|
|00003660| 76 61 72 7b 65 6e 64 7d | 3b 20 69 66 20 5c 76 61 |var{end}|; if \va|
|00003670| 72 7b 73 74 65 70 7d 20 | 69 73 20 6e 65 67 61 74 |r{step} |is negat|
|00003680| 69 76 65 2c 20 74 68 65 | 20 6c 61 73 74 0a 20 20 |ive, the| last. |
|00003690| 65 6c 65 6d 65 6e 74 20 | 69 73 20 74 68 65 20 6c |element |is the l|
|000036a0| 61 72 67 65 73 74 20 5c | 63 6f 64 65 7b 5c 76 61 |argest \|code{\va|
|000036b0| 72 7b 73 74 61 72 74 7d | 20 2b 20 5c 76 61 72 7b |r{start}| + \var{|
|000036c0| 69 7d 20 2a 20 5c 76 61 | 72 7b 73 74 65 70 7d 7d |i} * \va|r{step}}|
|000036d0| 0a 20 20 67 72 65 61 74 | 65 72 20 74 68 61 6e 20 |. great|er than |
|000036e0| 5c 76 61 72 7b 65 6e 64 | 7d 2e 20 20 5c 76 61 72 |\var{end|}. \var|
|000036f0| 7b 73 74 65 70 7d 20 6d | 75 73 74 20 6e 6f 74 20 |{step} m|ust not |
|00003700| 62 65 20 7a 65 72 6f 20 | 28 6f 72 20 65 6c 73 65 |be zero |(or else|
|00003710| 20 61 6e 0a 20 20 65 78 | 63 65 70 74 69 6f 6e 20 | an. ex|ception |
|00003720| 69 73 20 72 61 69 73 65 | 64 29 2e 20 20 45 78 61 |is raise|d). Exa|
|00003730| 6d 70 6c 65 3a 0a 0a 5c | 62 63 6f 64 65 5c 62 65 |mple:..\|bcode\be|
|00003740| 67 69 6e 7b 76 65 72 62 | 61 74 69 6d 7d 0a 3e 3e |gin{verb|atim}.>>|
|00003750| 3e 20 72 61 6e 67 65 28 | 31 30 29 0a 5b 30 2c 20 |> range(|10).[0, |
|00003760| 31 2c 20 32 2c 20 33 2c | 20 34 2c 20 35 2c 20 36 |1, 2, 3,| 4, 5, 6|
|00003770| 2c 20 37 2c 20 38 2c 20 | 39 5d 0a 3e 3e 3e 20 72 |, 7, 8, |9].>>> r|
|00003780| 61 6e 67 65 28 31 2c 20 | 31 31 29 0a 5b 31 2c 20 |ange(1, |11).[1, |
|00003790| 32 2c 20 33 2c 20 34 2c | 20 35 2c 20 36 2c 20 37 |2, 3, 4,| 5, 6, 7|
|000037a0| 2c 20 38 2c 20 39 2c 20 | 31 30 5d 0a 3e 3e 3e 20 |, 8, 9, |10].>>> |
|000037b0| 72 61 6e 67 65 28 30 2c | 20 33 30 2c 20 35 29 0a |range(0,| 30, 5).|
|000037c0| 5b 30 2c 20 35 2c 20 31 | 30 2c 20 31 35 2c 20 32 |[0, 5, 1|0, 15, 2|
|000037d0| 30 2c 20 32 35 5d 0a 3e | 3e 3e 20 72 61 6e 67 65 |0, 25].>|>> range|
|000037e0| 28 30 2c 20 31 30 2c 20 | 33 29 0a 5b 30 2c 20 33 |(0, 10, |3).[0, 3|
|000037f0| 2c 20 36 2c 20 39 5d 0a | 3e 3e 3e 20 72 61 6e 67 |, 6, 9].|>>> rang|
|00003800| 65 28 30 2c 20 2d 31 30 | 2c 20 2d 31 29 0a 5b 30 |e(0, -10|, -1).[0|
|00003810| 2c 20 2d 31 2c 20 2d 32 | 2c 20 2d 33 2c 20 2d 34 |, -1, -2|, -3, -4|
|00003820| 2c 20 2d 35 2c 20 2d 36 | 2c 20 2d 37 2c 20 2d 38 |, -5, -6|, -7, -8|
|00003830| 2c 20 2d 39 5d 0a 3e 3e | 3e 20 72 61 6e 67 65 28 |, -9].>>|> range(|
|00003840| 30 29 0a 5b 5d 0a 3e 3e | 3e 20 72 61 6e 67 65 28 |0).[].>>|> range(|
|00003850| 31 2c 20 30 29 0a 5b 5d | 0a 3e 3e 3e 20 0a 5c 65 |1, 0).[]|.>>> .\e|
|00003860| 6e 64 7b 76 65 72 62 61 | 74 69 6d 7d 5c 65 63 6f |nd{verba|tim}\eco|
|00003870| 64 65 0a 5c 65 6e 64 7b | 66 75 6e 63 64 65 73 63 |de.\end{|funcdesc|
|00003880| 7d 0a 0a 5c 62 65 67 69 | 6e 7b 66 75 6e 63 64 65 |}..\begi|n{funcde|
|00003890| 73 63 7d 7b 72 61 77 5f | 69 6e 70 75 74 7d 7b 5c |sc}{raw_|input}{\|
|000038a0| 6f 70 74 69 6f 6e 61 6c | 7b 70 72 6f 6d 70 74 7d |optional|{prompt}|
|000038b0| 7d 0a 20 20 49 66 20 74 | 68 65 20 5c 76 61 72 7b |}. If t|he \var{|
|000038c0| 70 72 6f 6d 70 74 7d 20 | 61 72 67 75 6d 65 6e 74 |prompt} |argument|
|000038d0| 20 69 73 20 70 72 65 73 | 65 6e 74 2c 20 69 74 20 | is pres|ent, it |
|000038e0| 69 73 20 77 72 69 74 74 | 65 6e 20 74 6f 20 73 74 |is writt|en to st|
|000038f0| 61 6e 64 61 72 64 20 6f | 75 74 70 75 74 0a 20 20 |andard o|utput. |
|00003900| 77 69 74 68 6f 75 74 20 | 61 20 74 72 61 69 6c 69 |without |a traili|
|00003910| 6e 67 20 6e 65 77 6c 69 | 6e 65 2e 20 20 54 68 65 |ng newli|ne. The|
|00003920| 20 66 75 6e 63 74 69 6f | 6e 20 74 68 65 6e 20 72 | functio|n then r|
|00003930| 65 61 64 73 20 61 20 6c | 69 6e 65 20 66 72 6f 6d |eads a l|ine from|
|00003940| 20 69 6e 70 75 74 2c 0a | 20 20 63 6f 6e 76 65 72 | input,.| conver|
|00003950| 74 73 20 69 74 20 74 6f | 20 61 20 73 74 72 69 6e |ts it to| a strin|
|00003960| 67 20 28 73 74 72 69 70 | 70 69 6e 67 20 61 20 74 |g (strip|ping a t|
|00003970| 72 61 69 6c 69 6e 67 20 | 6e 65 77 6c 69 6e 65 29 |railing |newline)|
|00003980| 2c 20 61 6e 64 20 72 65 | 74 75 72 6e 73 20 74 68 |, and re|turns th|
|00003990| 61 74 2e 0a 20 20 57 68 | 65 6e 20 5c 45 4f 46 7b |at.. Wh|en \EOF{|
|000039a0| 7d 20 69 73 20 72 65 61 | 64 2c 20 5c 63 6f 64 65 |} is rea|d, \code|
|000039b0| 7b 45 4f 46 45 72 72 6f | 72 7d 20 69 73 20 72 61 |{EOFErro|r} is ra|
|000039c0| 69 73 65 64 2e 20 45 78 | 61 6d 70 6c 65 3a 0a 0a |ised. Ex|ample:..|
|000039d0| 5c 62 63 6f 64 65 5c 62 | 65 67 69 6e 7b 76 65 72 |\bcode\b|egin{ver|
|000039e0| 62 61 74 69 6d 7d 0a 3e | 3e 3e 20 73 20 3d 20 72 |batim}.>|>> s = r|
|000039f0| 61 77 5f 69 6e 70 75 74 | 28 27 2d 2d 3e 20 27 29 |aw_input|('--> ')|
|00003a00| 0a 2d 2d 3e 20 4d 6f 6e | 74 79 20 50 79 74 68 6f |.--> Mon|ty Pytho|
|00003a10| 6e 27 73 20 46 6c 79 69 | 6e 67 20 43 69 72 63 75 |n's Flyi|ng Circu|
|00003a20| 73 0a 3e 3e 3e 20 73 0a | 22 4d 6f 6e 74 79 20 50 |s.>>> s.|"Monty P|
|00003a30| 79 74 68 6f 6e 27 73 20 | 46 6c 79 69 6e 67 20 43 |ython's |Flying C|
|00003a40| 69 72 63 75 73 22 0a 3e | 3e 3e 20 0a 5c 65 6e 64 |ircus".>|>> .\end|
|00003a50| 7b 76 65 72 62 61 74 69 | 6d 7d 5c 65 63 6f 64 65 |{verbati|m}\ecode|
|00003a60| 0a 5c 65 6e 64 7b 66 75 | 6e 63 64 65 73 63 7d 0a |.\end{fu|ncdesc}.|
|00003a70| 0a 5c 62 65 67 69 6e 7b | 66 75 6e 63 64 65 73 63 |.\begin{|funcdesc|
|00003a80| 7d 7b 72 65 64 75 63 65 | 7d 7b 66 75 6e 63 74 69 |}{reduce|}{functi|
|00003a90| 6f 6e 5c 2c 20 6c 69 73 | 74 5c 6f 70 74 69 6f 6e |on\, lis|t\option|
|00003aa0| 61 6c 7b 5c 2c 20 69 6e | 69 74 69 61 6c 69 7a 65 |al{\, in|itialize|
|00003ab0| 72 7d 7d 0a 41 70 70 6c | 79 20 74 68 65 20 62 69 |r}}.Appl|y the bi|
|00003ac0| 6e 61 72 79 20 5c 76 61 | 72 7b 66 75 6e 63 74 69 |nary \va|r{functi|
|00003ad0| 6f 6e 7d 20 74 6f 20 74 | 68 65 20 69 74 65 6d 73 |on} to t|he items|
|00003ae0| 20 6f 66 20 5c 76 61 72 | 7b 6c 69 73 74 7d 20 73 | of \var|{list} s|
|00003af0| 6f 20 61 73 20 74 6f 0a | 72 65 64 75 63 65 20 74 |o as to.|reduce t|
|00003b00| 68 65 20 6c 69 73 74 20 | 74 6f 20 61 20 73 69 6e |he list |to a sin|
|00003b10| 67 6c 65 20 76 61 6c 75 | 65 2e 20 20 45 2e 67 2e |gle valu|e. E.g.|
|00003b20| 2c 0a 5c 63 6f 64 65 7b | 72 65 64 75 63 65 28 6c |,.\code{|reduce(l|
|00003b30| 61 6d 62 64 61 20 78 2c | 20 79 3a 20 78 2a 79 2c |ambda x,| y: x*y,|
|00003b40| 20 5c 76 61 72 7b 6c 69 | 73 74 7d 2c 20 31 29 7d | \var{li|st}, 1)}|
|00003b50| 20 72 65 74 75 72 6e 73 | 20 74 68 65 20 70 72 6f | returns| the pro|
|00003b60| 64 75 63 74 20 6f 66 0a | 74 68 65 20 65 6c 65 6d |duct of.|the elem|
|00003b70| 65 6e 74 73 20 6f 66 20 | 5c 76 61 72 7b 6c 69 73 |ents of |\var{lis|
|00003b80| 74 7d 2e 20 20 54 68 65 | 20 6f 70 74 69 6f 6e 61 |t}. The| optiona|
|00003b90| 6c 20 5c 76 61 72 7b 69 | 6e 69 74 69 61 6c 69 7a |l \var{i|nitializ|
|00003ba0| 65 72 7d 20 63 61 6e 20 | 62 65 0a 74 68 6f 75 67 |er} can |be.thoug|
|00003bb0| 68 74 20 6f 66 20 61 73 | 20 62 65 69 6e 67 20 70 |ht of as| being p|
|00003bc0| 72 65 70 65 6e 64 65 64 | 20 74 6f 20 5c 76 61 72 |repended| to \var|
|00003bd0| 7b 6c 69 73 74 7d 20 73 | 6f 20 61 73 20 74 6f 20 |{list} s|o as to |
|00003be0| 61 6c 6c 6f 77 20 72 65 | 64 75 63 74 69 6f 6e 0a |allow re|duction.|
|00003bf0| 6f 66 20 61 6e 20 65 6d | 70 74 79 20 5c 76 61 72 |of an em|pty \var|
|00003c00| 7b 6c 69 73 74 7d 2e 20 | 20 54 68 65 20 5c 76 61 |{list}. | The \va|
|00003c10| 72 7b 6c 69 73 74 7d 20 | 61 72 67 75 6d 65 6e 74 |r{list} |argument|
|00003c20| 73 20 6d 61 79 20 62 65 | 20 61 6e 79 20 6b 69 6e |s may be| any kin|
|00003c30| 64 20 6f 66 0a 73 65 71 | 75 65 6e 63 65 2e 0a 5c |d of.seq|uence..\|
|00003c40| 65 6e 64 7b 66 75 6e 63 | 64 65 73 63 7d 0a 0a 5c |end{func|desc}..\|
|00003c50| 62 65 67 69 6e 7b 66 75 | 6e 63 64 65 73 63 7d 7b |begin{fu|ncdesc}{|
|00003c60| 72 65 6c 6f 61 64 7d 7b | 6d 6f 64 75 6c 65 7d 0a |reload}{|module}.|
|00003c70| 52 65 2d 70 61 72 73 65 | 20 61 6e 64 20 72 65 2d |Re-parse| and re-|
|00003c80| 69 6e 69 74 69 61 6c 69 | 7a 65 20 61 6e 20 61 6c |initiali|ze an al|
|00003c90| 72 65 61 64 79 20 69 6d | 70 6f 72 74 65 64 20 5c |ready im|ported \|
|00003ca0| 76 61 72 7b 6d 6f 64 75 | 6c 65 7d 2e 20 20 54 68 |var{modu|le}. Th|
|00003cb0| 65 0a 61 72 67 75 6d 65 | 6e 74 20 6d 75 73 74 20 |e.argume|nt must |
|00003cc0| 62 65 20 61 20 6d 6f 64 | 75 6c 65 20 6f 62 6a 65 |be a mod|ule obje|
|00003cd0| 63 74 2c 20 73 6f 20 69 | 74 20 6d 75 73 74 20 68 |ct, so i|t must h|
|00003ce0| 61 76 65 20 62 65 65 6e | 20 73 75 63 63 65 73 73 |ave been| success|
|00003cf0| 66 75 6c 6c 79 0a 69 6d | 70 6f 72 74 65 64 20 62 |fully.im|ported b|
|00003d00| 65 66 6f 72 65 2e 20 20 | 54 68 69 73 20 69 73 20 |efore. |This is |
|00003d10| 75 73 65 66 75 6c 20 69 | 66 20 79 6f 75 20 68 61 |useful i|f you ha|
|00003d20| 76 65 20 65 64 69 74 65 | 64 20 74 68 65 20 6d 6f |ve edite|d the mo|
|00003d30| 64 75 6c 65 20 73 6f 75 | 72 63 65 0a 66 69 6c 65 |dule sou|rce.file|
|00003d40| 20 75 73 69 6e 67 20 61 | 6e 20 65 78 74 65 72 6e | using a|n extern|
|00003d50| 61 6c 20 65 64 69 74 6f | 72 20 61 6e 64 20 77 61 |al edito|r and wa|
|00003d60| 6e 74 20 74 6f 20 74 72 | 79 20 6f 75 74 20 74 68 |nt to tr|y out th|
|00003d70| 65 20 6e 65 77 20 76 65 | 72 73 69 6f 6e 0a 77 69 |e new ve|rsion.wi|
|00003d80| 74 68 6f 75 74 20 6c 65 | 61 76 69 6e 67 20 74 68 |thout le|aving th|
|00003d90| 65 20 50 79 74 68 6f 6e | 20 69 6e 74 65 72 70 72 |e Python| interpr|
|00003da0| 65 74 65 72 2e 20 20 54 | 68 65 20 72 65 74 75 72 |eter. T|he retur|
|00003db0| 6e 20 76 61 6c 75 65 20 | 69 73 20 74 68 65 0a 6d |n value |is the.m|
|00003dc0| 6f 64 75 6c 65 20 6f 62 | 6a 65 63 74 20 28 69 2e |odule ob|ject (i.|
|00003dd0| 65 2e 5c 20 74 68 65 20 | 73 61 6d 65 20 61 73 20 |e.\ the |same as |
|00003de0| 74 68 65 20 5c 76 61 72 | 7b 6d 6f 64 75 6c 65 7d |the \var|{module}|
|00003df0| 20 61 72 67 75 6d 65 6e | 74 29 2e 0a 0a 54 68 65 | argumen|t)...The|
|00003e00| 72 65 20 61 72 65 20 61 | 20 6e 75 6d 62 65 72 20 |re are a| number |
|00003e10| 6f 66 20 63 61 76 65 61 | 74 73 3a 0a 0a 49 66 20 |of cavea|ts:..If |
|00003e20| 61 20 6d 6f 64 75 6c 65 | 20 69 73 20 73 79 6e 74 |a module| is synt|
|00003e30| 61 63 74 69 63 61 6c 6c | 79 20 63 6f 72 72 65 63 |acticall|y correc|
|00003e40| 74 20 62 75 74 20 69 74 | 73 20 69 6e 69 74 69 61 |t but it|s initia|
|00003e50| 6c 69 7a 61 74 69 6f 6e | 20 66 61 69 6c 73 2c 20 |lization| fails, |
|00003e60| 74 68 65 0a 66 69 72 73 | 74 20 5c 63 6f 64 65 7b |the.firs|t \code{|
|00003e70| 69 6d 70 6f 72 74 7d 20 | 73 74 61 74 65 6d 65 6e |import} |statemen|
|00003e80| 74 20 66 6f 72 20 69 74 | 20 64 6f 65 73 20 6e 6f |t for it| does no|
|00003e90| 74 20 62 69 6e 64 20 69 | 74 73 20 6e 61 6d 65 20 |t bind i|ts name |
|00003ea0| 6c 6f 63 61 6c 6c 79 2c | 0a 62 75 74 20 64 6f 65 |locally,|.but doe|
|00003eb0| 73 20 73 74 6f 72 65 20 | 61 20 28 70 61 72 74 69 |s store |a (parti|
|00003ec0| 61 6c 6c 79 20 69 6e 69 | 74 69 61 6c 69 7a 65 64 |ally ini|tialized|
|00003ed0| 29 20 6d 6f 64 75 6c 65 | 20 6f 62 6a 65 63 74 20 |) module| object |
|00003ee0| 69 6e 0a 5c 63 6f 64 65 | 7b 73 79 73 2e 6d 6f 64 |in.\code|{sys.mod|
|00003ef0| 75 6c 65 73 7d 2e 20 20 | 54 6f 20 72 65 6c 6f 61 |ules}. |To reloa|
|00003f00| 64 20 74 68 65 20 6d 6f | 64 75 6c 65 20 79 6f 75 |d the mo|dule you|
|00003f10| 20 6d 75 73 74 20 66 69 | 72 73 74 0a 5c 63 6f 64 | must fi|rst.\cod|
|00003f20| 65 7b 69 6d 70 6f 72 74 | 7d 20 69 74 20 61 67 61 |e{import|} it aga|
|00003f30| 69 6e 20 28 74 68 69 73 | 20 77 69 6c 6c 20 62 69 |in (this| will bi|
|00003f40| 6e 64 20 74 68 65 20 6e | 61 6d 65 20 74 6f 20 74 |nd the n|ame to t|
|00003f50| 68 65 20 70 61 72 74 69 | 61 6c 6c 79 0a 69 6e 69 |he parti|ally.ini|
|00003f60| 74 69 61 6c 69 7a 65 64 | 20 6d 6f 64 75 6c 65 20 |tialized| module |
|00003f70| 6f 62 6a 65 63 74 29 20 | 62 65 66 6f 72 65 20 79 |object) |before y|
|00003f80| 6f 75 20 63 61 6e 20 5c | 63 6f 64 65 7b 72 65 6c |ou can \|code{rel|
|00003f90| 6f 61 64 28 29 7d 20 69 | 74 2e 0a 0a 57 68 65 6e |oad()} i|t...When|
|00003fa0| 20 61 20 6d 6f 64 75 6c | 65 20 69 73 20 72 65 6c | a modul|e is rel|
|00003fb0| 6f 61 64 65 64 2c 20 69 | 74 73 20 64 69 63 74 69 |oaded, i|ts dicti|
|00003fc0| 6f 6e 61 72 79 20 28 63 | 6f 6e 74 61 69 6e 69 6e |onary (c|ontainin|
|00003fd0| 67 20 74 68 65 20 6d 6f | 64 75 6c 65 27 73 0a 67 |g the mo|dule's.g|
|00003fe0| 6c 6f 62 61 6c 20 76 61 | 72 69 61 62 6c 65 73 29 |lobal va|riables)|
|00003ff0| 20 69 73 20 72 65 74 61 | 69 6e 65 64 2e 20 20 52 | is reta|ined. R|
|00004000| 65 64 65 66 69 6e 69 74 | 69 6f 6e 73 20 6f 66 20 |edefinit|ions of |
|00004010| 6e 61 6d 65 73 20 77 69 | 6c 6c 20 6f 76 65 72 72 |names wi|ll overr|
|00004020| 69 64 65 0a 74 68 65 20 | 6f 6c 64 20 64 65 66 69 |ide.the |old defi|
|00004030| 6e 69 74 69 6f 6e 73 2c | 20 73 6f 20 74 68 69 73 |nitions,| so this|
|00004040| 20 69 73 20 67 65 6e 65 | 72 61 6c 6c 79 20 6e 6f | is gene|rally no|
|00004050| 74 20 61 20 70 72 6f 62 | 6c 65 6d 2e 20 20 49 66 |t a prob|lem. If|
|00004060| 20 74 68 65 20 6e 65 77 | 0a 76 65 72 73 69 6f 6e | the new|.version|
|00004070| 20 6f 66 20 61 20 6d 6f | 64 75 6c 65 20 64 6f 65 | of a mo|dule doe|
|00004080| 73 20 6e 6f 74 20 64 65 | 66 69 6e 65 20 61 20 6e |s not de|fine a n|
|00004090| 61 6d 65 20 74 68 61 74 | 20 77 61 73 20 64 65 66 |ame that| was def|
|000040a0| 69 6e 65 64 20 62 79 20 | 74 68 65 20 6f 6c 64 0a |ined by |the old.|
|000040b0| 76 65 72 73 69 6f 6e 2c | 20 74 68 65 20 6f 6c 64 |version,| the old|
|000040c0| 20 64 65 66 69 6e 69 74 | 69 6f 6e 20 72 65 6d 61 | definit|ion rema|
|000040d0| 69 6e 73 2e 20 20 54 68 | 69 73 20 66 65 61 74 75 |ins. Th|is featu|
|000040e0| 72 65 20 63 61 6e 20 62 | 65 20 75 73 65 64 20 74 |re can b|e used t|
|000040f0| 6f 20 74 68 65 0a 6d 6f | 64 75 6c 65 27 73 20 61 |o the.mo|dule's a|
|00004100| 64 76 61 6e 74 61 67 65 | 20 69 66 20 69 74 20 6d |dvantage| if it m|
|00004110| 61 69 6e 74 61 69 6e 73 | 20 61 20 67 6c 6f 62 61 |aintains| a globa|
|00004120| 6c 20 74 61 62 6c 65 20 | 6f 72 20 63 61 63 68 65 |l table |or cache|
|00004130| 20 6f 66 20 6f 62 6a 65 | 63 74 73 0a 2d 2d 2d 20 | of obje|cts.--- |
|00004140| 77 69 74 68 20 61 20 5c | 63 6f 64 65 7b 74 72 79 |with a \|code{try|
|00004150| 7d 20 73 74 61 74 65 6d | 65 6e 74 20 69 74 20 63 |} statem|ent it c|
|00004160| 61 6e 20 74 65 73 74 20 | 66 6f 72 20 74 68 65 20 |an test |for the |
|00004170| 74 61 62 6c 65 27 73 20 | 70 72 65 73 65 6e 63 65 |table's |presence|
|00004180| 0a 61 6e 64 20 73 6b 69 | 70 20 69 74 73 20 69 6e |.and ski|p its in|
|00004190| 69 74 69 61 6c 69 7a 61 | 74 69 6f 6e 20 69 66 20 |itializa|tion if |
|000041a0| 64 65 73 69 72 65 64 2e | 0a 0a 49 74 20 69 73 20 |desired.|..It is |
|000041b0| 6c 65 67 61 6c 20 74 68 | 6f 75 67 68 20 67 65 6e |legal th|ough gen|
|000041c0| 65 72 61 6c 6c 79 20 6e | 6f 74 20 76 65 72 79 20 |erally n|ot very |
|000041d0| 75 73 65 66 75 6c 20 74 | 6f 20 72 65 6c 6f 61 64 |useful t|o reload|
|000041e0| 20 62 75 69 6c 74 2d 69 | 6e 20 6f 72 0a 64 79 6e | built-i|n or.dyn|
|000041f0| 61 6d 69 63 61 6c 6c 79 | 20 6c 6f 61 64 65 64 20 |amically| loaded |
|00004200| 6d 6f 64 75 6c 65 73 2c | 20 65 78 63 65 70 74 20 |modules,| except |
|00004210| 66 6f 72 20 5c 63 6f 64 | 65 7b 73 79 73 7d 2c 20 |for \cod|e{sys}, |
|00004220| 5c 63 6f 64 65 7b 5f 5f | 6d 61 69 6e 5f 5f 7d 20 |\code{__|main__} |
|00004230| 61 6e 64 0a 5c 63 6f 64 | 65 7b 5f 5f 62 75 69 6c |and.\cod|e{__buil|
|00004240| 74 69 6e 5f 5f 7d 2e 20 | 20 49 6e 20 63 65 72 74 |tin__}. | In cert|
|00004250| 61 69 6e 20 63 61 73 65 | 73 2c 20 68 6f 77 65 76 |ain case|s, howev|
|00004260| 65 72 2c 20 65 78 74 65 | 6e 73 69 6f 6e 20 6d 6f |er, exte|nsion mo|
|00004270| 64 75 6c 65 73 20 61 72 | 65 0a 6e 6f 74 20 64 65 |dules ar|e.not de|
|00004280| 73 69 67 6e 65 64 20 74 | 6f 20 62 65 20 69 6e 69 |signed t|o be ini|
|00004290| 74 69 61 6c 69 7a 65 64 | 20 6d 6f 72 65 20 74 68 |tialized| more th|
|000042a0| 61 6e 20 6f 6e 63 65 2c | 20 61 6e 64 20 6d 61 79 |an once,| and may|
|000042b0| 20 66 61 69 6c 20 69 6e | 0a 61 72 62 69 74 72 61 | fail in|.arbitra|
|000042c0| 72 79 20 77 61 79 73 20 | 77 68 65 6e 20 72 65 6c |ry ways |when rel|
|000042d0| 6f 61 64 65 64 2e 0a 0a | 49 66 20 61 20 6d 6f 64 |oaded...|If a mod|
|000042e0| 75 6c 65 20 69 6d 70 6f | 72 74 73 20 6f 62 6a 65 |ule impo|rts obje|
|000042f0| 63 74 73 20 66 72 6f 6d | 20 61 6e 6f 74 68 65 72 |cts from| another|
|00004300| 20 6d 6f 64 75 6c 65 20 | 75 73 69 6e 67 20 5c 63 | module |using \c|
|00004310| 6f 64 65 7b 66 72 6f 6d | 7d 0a 7b 5c 6c 64 6f 74 |ode{from|}.{\ldot|
|00004320| 73 7d 20 5c 63 6f 64 65 | 7b 69 6d 70 6f 72 74 7d |s} \code|{import}|
|00004330| 20 7b 5c 6c 64 6f 74 73 | 7d 2c 20 63 61 6c 6c 69 | {\ldots|}, calli|
|00004340| 6e 67 20 5c 63 6f 64 65 | 7b 72 65 6c 6f 61 64 28 |ng \code|{reload(|
|00004350| 29 7d 20 66 6f 72 20 74 | 68 65 20 6f 74 68 65 72 |)} for t|he other|
|00004360| 0a 6d 6f 64 75 6c 65 20 | 64 6f 65 73 20 6e 6f 74 |.module |does not|
|00004370| 20 72 65 64 65 66 69 6e | 65 20 74 68 65 20 6f 62 | redefin|e the ob|
|00004380| 6a 65 63 74 73 20 69 6d | 70 6f 72 74 65 64 20 66 |jects im|ported f|
|00004390| 72 6f 6d 20 69 74 20 2d | 2d 2d 20 6f 6e 65 20 77 |rom it -|-- one w|
|000043a0| 61 79 0a 61 72 6f 75 6e | 64 20 74 68 69 73 20 69 |ay.aroun|d this i|
|000043b0| 73 20 74 6f 20 72 65 2d | 65 78 65 63 75 74 65 20 |s to re-|execute |
|000043c0| 74 68 65 20 5c 63 6f 64 | 65 7b 66 72 6f 6d 7d 20 |the \cod|e{from} |
|000043d0| 73 74 61 74 65 6d 65 6e | 74 2c 20 61 6e 6f 74 68 |statemen|t, anoth|
|000043e0| 65 72 20 69 73 20 74 6f | 0a 75 73 65 20 5c 63 6f |er is to|.use \co|
|000043f0| 64 65 7b 69 6d 70 6f 72 | 74 7d 20 61 6e 64 20 71 |de{impor|t} and q|
|00004400| 75 61 6c 69 66 69 65 64 | 20 6e 61 6d 65 73 20 28 |ualified| names (|
|00004410| 5c 76 61 72 7b 6d 6f 64 | 75 6c 65 7d 2e 5c 76 61 |\var{mod|ule}.\va|
|00004420| 72 7b 6e 61 6d 65 7d 29 | 0a 69 6e 73 74 65 61 64 |r{name})|.instead|
|00004430| 2e 0a 0a 49 66 20 61 20 | 6d 6f 64 75 6c 65 20 69 |...If a |module i|
|00004440| 6e 73 74 61 6e 74 69 61 | 74 65 73 20 69 6e 73 74 |nstantia|tes inst|
|00004450| 61 6e 63 65 73 20 6f 66 | 20 61 20 63 6c 61 73 73 |ances of| a class|
|00004460| 2c 20 72 65 6c 6f 61 64 | 69 6e 67 20 74 68 65 20 |, reload|ing the |
|00004470| 6d 6f 64 75 6c 65 0a 74 | 68 61 74 20 64 65 66 69 |module.t|hat defi|
|00004480| 6e 65 73 20 74 68 65 20 | 63 6c 61 73 73 20 64 6f |nes the |class do|
|00004490| 65 73 20 6e 6f 74 20 61 | 66 66 65 63 74 20 74 68 |es not a|ffect th|
|000044a0| 65 20 6d 65 74 68 6f 64 | 20 64 65 66 69 6e 69 74 |e method| definit|
|000044b0| 69 6f 6e 73 20 6f 66 20 | 74 68 65 0a 69 6e 73 74 |ions of |the.inst|
|000044c0| 61 6e 63 65 73 20 2d 2d | 2d 20 74 68 65 79 20 63 |ances --|- they c|
|000044d0| 6f 6e 74 69 6e 75 65 20 | 74 6f 20 75 73 65 20 74 |ontinue |to use t|
|000044e0| 68 65 20 6f 6c 64 20 63 | 6c 61 73 73 20 64 65 66 |he old c|lass def|
|000044f0| 69 6e 69 74 69 6f 6e 2e | 20 20 54 68 65 20 73 61 |inition.| The sa|
|00004500| 6d 65 0a 69 73 20 74 72 | 75 65 20 66 6f 72 20 64 |me.is tr|ue for d|
|00004510| 65 72 69 76 65 64 20 63 | 6c 61 73 73 65 73 2e 0a |erived c|lasses..|
|00004520| 5c 65 6e 64 7b 66 75 6e | 63 64 65 73 63 7d 0a 0a |\end{fun|cdesc}..|
|00004530| 5c 62 65 67 69 6e 7b 66 | 75 6e 63 64 65 73 63 7d |\begin{f|uncdesc}|
|00004540| 7b 72 65 70 72 7d 7b 6f | 62 6a 65 63 74 7d 0a 52 |{repr}{o|bject}.R|
|00004550| 65 74 75 72 6e 20 61 20 | 73 74 72 69 6e 67 20 63 |eturn a |string c|
|00004560| 6f 6e 74 61 69 6e 69 6e | 67 20 61 20 70 72 69 6e |ontainin|g a prin|
|00004570| 74 61 62 6c 65 20 72 65 | 70 72 65 73 65 6e 74 61 |table re|presenta|
|00004580| 74 69 6f 6e 20 6f 66 20 | 61 6e 20 6f 62 6a 65 63 |tion of |an objec|
|00004590| 74 2e 0a 54 68 69 73 20 | 69 73 20 74 68 65 20 73 |t..This |is the s|
|000045a0| 61 6d 65 20 76 61 6c 75 | 65 20 79 69 65 6c 64 65 |ame valu|e yielde|
|000045b0| 64 20 62 79 20 63 6f 6e | 76 65 72 73 69 6f 6e 73 |d by con|versions|
|000045c0| 20 28 72 65 76 65 72 73 | 65 20 71 75 6f 74 65 73 | (revers|e quotes|
|000045d0| 29 2e 0a 49 74 20 69 73 | 20 73 6f 6d 65 74 69 6d |)..It is| sometim|
|000045e0| 65 73 20 75 73 65 66 75 | 6c 20 74 6f 20 62 65 20 |es usefu|l to be |
|000045f0| 61 62 6c 65 20 74 6f 20 | 61 63 63 65 73 73 20 74 |able to |access t|
|00004600| 68 69 73 20 6f 70 65 72 | 61 74 69 6f 6e 20 61 73 |his oper|ation as|
|00004610| 20 61 6e 0a 6f 72 64 69 | 6e 61 72 79 20 66 75 6e | an.ordi|nary fun|
|00004620| 63 74 69 6f 6e 2e 20 20 | 46 6f 72 20 6d 61 6e 79 |ction. |For many|
|00004630| 20 74 79 70 65 73 2c 20 | 74 68 69 73 20 66 75 6e | types, |this fun|
|00004640| 63 74 69 6f 6e 20 6d 61 | 6b 65 73 20 61 6e 20 61 |ction ma|kes an a|
|00004650| 74 74 65 6d 70 74 0a 74 | 6f 20 72 65 74 75 72 6e |ttempt.t|o return|
|00004660| 20 61 20 73 74 72 69 6e | 67 20 74 68 61 74 20 77 | a strin|g that w|
|00004670| 6f 75 6c 64 20 79 69 65 | 6c 64 20 61 6e 20 6f 62 |ould yie|ld an ob|
|00004680| 6a 65 63 74 20 77 69 74 | 68 20 74 68 65 20 73 61 |ject wit|h the sa|
|00004690| 6d 65 20 76 61 6c 75 65 | 0a 77 68 65 6e 20 70 61 |me value|.when pa|
|000046a0| 73 73 65 64 20 74 6f 20 | 5c 63 6f 64 65 7b 65 76 |ssed to |\code{ev|
|000046b0| 61 6c 28 29 7d 2e 0a 5c | 65 6e 64 7b 66 75 6e 63 |al()}..\|end{func|
|000046c0| 64 65 73 63 7d 0a 0a 5c | 62 65 67 69 6e 7b 66 75 |desc}..\|begin{fu|
|000046d0| 6e 63 64 65 73 63 7d 7b | 72 6f 75 6e 64 7d 7b 78 |ncdesc}{|round}{x|
|000046e0| 5c 2c 20 6e 7d 0a 20 20 | 52 65 74 75 72 6e 20 74 |\, n}. |Return t|
|000046f0| 68 65 20 66 6c 6f 61 74 | 69 6e 67 20 70 6f 69 6e |he float|ing poin|
|00004700| 74 20 76 61 6c 75 65 20 | 5c 76 61 72 7b 78 7d 20 |t value |\var{x} |
|00004710| 72 6f 75 6e 64 65 64 20 | 74 6f 20 5c 76 61 72 7b |rounded |to \var{|
|00004720| 6e 7d 20 64 69 67 69 74 | 73 0a 20 20 61 66 74 65 |n} digit|s. afte|
|00004730| 72 20 74 68 65 20 64 65 | 63 69 6d 61 6c 20 70 6f |r the de|cimal po|
|00004740| 69 6e 74 2e 20 20 49 66 | 20 5c 76 61 72 7b 6e 7d |int. If| \var{n}|
|00004750| 20 69 73 20 6f 6d 69 74 | 74 65 64 2c 20 69 74 20 | is omit|ted, it |
|00004760| 64 65 66 61 75 6c 74 73 | 20 74 6f 20 7a 65 72 6f |defaults| to zero|
|00004770| 2e 0a 20 20 54 68 65 20 | 72 65 73 75 6c 74 20 69 |.. The |result i|
|00004780| 73 20 61 20 66 6c 6f 61 | 74 69 6e 67 20 70 6f 69 |s a floa|ting poi|
|00004790| 6e 74 20 6e 75 6d 62 65 | 72 2e 20 20 56 61 6c 75 |nt numbe|r. Valu|
|000047a0| 65 73 20 61 72 65 20 72 | 6f 75 6e 64 65 64 20 74 |es are r|ounded t|
|000047b0| 6f 20 74 68 65 0a 20 20 | 63 6c 6f 73 65 73 74 20 |o the. |closest |
|000047c0| 6d 75 6c 74 69 70 6c 65 | 20 6f 66 20 31 30 20 74 |multiple| of 10 t|
|000047d0| 6f 20 74 68 65 20 70 6f | 77 65 72 20 6d 69 6e 75 |o the po|wer minu|
|000047e0| 73 20 5c 76 61 72 7b 6e | 7d 3b 20 69 66 20 74 77 |s \var{n|}; if tw|
|000047f0| 6f 20 6d 75 6c 74 69 70 | 6c 65 73 0a 20 20 61 72 |o multip|les. ar|
|00004800| 65 20 65 71 75 61 6c 6c | 79 20 63 6c 6f 73 65 2c |e equall|y close,|
|00004810| 20 72 6f 75 6e 64 69 6e | 67 20 69 73 20 64 6f 6e | roundin|g is don|
|00004820| 65 20 61 77 61 79 20 66 | 72 6f 6d 20 30 20 28 73 |e away f|rom 0 (s|
|00004830| 6f 20 65 2e 67 2e 0a 20 | 20 5c 63 6f 64 65 7b 72 |o e.g.. | \code{r|
|00004840| 6f 75 6e 64 28 30 2e 35 | 29 7d 20 69 73 20 5c 63 |ound(0.5|)} is \c|
|00004850| 6f 64 65 7b 31 2e 30 7d | 20 61 6e 64 20 5c 63 6f |ode{1.0}| and \co|
|00004860| 64 65 7b 72 6f 75 6e 64 | 28 2d 30 2e 35 29 7d 20 |de{round|(-0.5)} |
|00004870| 69 73 20 5c 63 6f 64 65 | 7b 2d 31 2e 30 7d 29 2e |is \code|{-1.0}).|
|00004880| 0a 5c 65 6e 64 7b 66 75 | 6e 63 64 65 73 63 7d 0a |.\end{fu|ncdesc}.|
|00004890| 0a 5c 62 65 67 69 6e 7b | 66 75 6e 63 64 65 73 63 |.\begin{|funcdesc|
|000048a0| 7d 7b 73 65 74 61 74 74 | 72 7d 7b 6f 62 6a 65 63 |}{setatt|r}{objec|
|000048b0| 74 5c 2c 20 6e 61 6d 65 | 5c 2c 20 76 61 6c 75 65 |t\, name|\, value|
|000048c0| 7d 0a 20 20 54 68 69 73 | 20 69 73 20 74 68 65 20 |}. This| is the |
|000048d0| 63 6f 75 6e 74 65 72 70 | 61 72 74 20 6f 66 20 5c |counterp|art of \|
|000048e0| 63 6f 64 65 7b 67 65 74 | 61 74 74 72 7d 2e 20 20 |code{get|attr}. |
|000048f0| 54 68 65 20 61 72 67 75 | 6d 65 6e 74 73 20 61 72 |The argu|ments ar|
|00004900| 65 20 61 6e 0a 20 20 6f | 62 6a 65 63 74 2c 20 61 |e an. o|bject, a|
|00004910| 20 73 74 72 69 6e 67 20 | 61 6e 64 20 61 6e 20 61 | string |and an a|
|00004920| 72 62 69 74 72 61 72 79 | 20 76 61 6c 75 65 2e 20 |rbitrary| value. |
|00004930| 20 54 68 65 20 73 74 72 | 69 6e 67 20 6d 75 73 74 | The str|ing must|
|00004940| 20 62 65 20 74 68 65 20 | 6e 61 6d 65 0a 20 20 6f | be the |name. o|
|00004950| 66 20 6f 6e 65 20 6f 66 | 20 74 68 65 20 6f 62 6a |f one of| the obj|
|00004960| 65 63 74 27 73 20 61 74 | 74 72 69 62 75 74 65 73 |ect's at|tributes|
|00004970| 2e 20 20 54 68 65 20 66 | 75 6e 63 74 69 6f 6e 20 |. The f|unction |
|00004980| 61 73 73 69 67 6e 73 20 | 74 68 65 20 76 61 6c 75 |assigns |the valu|
|00004990| 65 20 74 6f 0a 20 20 74 | 68 65 20 61 74 74 72 69 |e to. t|he attri|
|000049a0| 62 75 74 65 2c 20 70 72 | 6f 76 69 64 65 64 20 74 |bute, pr|ovided t|
|000049b0| 68 65 20 6f 62 6a 65 63 | 74 20 61 6c 6c 6f 77 73 |he objec|t allows|
|000049c0| 20 69 74 2e 20 20 46 6f | 72 20 65 78 61 6d 70 6c | it. Fo|r exampl|
|000049d0| 65 2c 0a 20 20 5c 63 6f | 64 65 7b 73 65 74 61 74 |e,. \co|de{setat|
|000049e0| 74 72 28 5c 76 61 72 7b | 78 7d 2c 20 27 5c 76 61 |tr(\var{|x}, '\va|
|000049f0| 72 7b 66 6f 6f 62 61 72 | 7d 27 2c 20 31 32 33 29 |r{foobar|}', 123)|
|00004a00| 7d 20 69 73 20 65 71 75 | 69 76 61 6c 65 6e 74 20 |} is equ|ivalent |
|00004a10| 74 6f 0a 20 20 5c 63 6f | 64 65 7b 5c 76 61 72 7b |to. \co|de{\var{|
|00004a20| 78 7d 2e 5c 76 61 72 7b | 66 6f 6f 62 61 72 7d 20 |x}.\var{|foobar} |
|00004a30| 3d 20 31 32 33 7d 2e 0a | 5c 65 6e 64 7b 66 75 6e |= 123}..|\end{fun|
|00004a40| 63 64 65 73 63 7d 0a 0a | 5c 62 65 67 69 6e 7b 66 |cdesc}..|\begin{f|
|00004a50| 75 6e 63 64 65 73 63 7d | 7b 73 74 72 7d 7b 6f 62 |uncdesc}|{str}{ob|
|00004a60| 6a 65 63 74 7d 0a 52 65 | 74 75 72 6e 20 61 20 73 |ject}.Re|turn a s|
|00004a70| 74 72 69 6e 67 20 63 6f | 6e 74 61 69 6e 69 6e 67 |tring co|ntaining|
|00004a80| 20 61 20 6e 69 63 65 6c | 79 20 70 72 69 6e 74 61 | a nicel|y printa|
|00004a90| 62 6c 65 20 72 65 70 72 | 65 73 65 6e 74 61 74 69 |ble repr|esentati|
|00004aa0| 6f 6e 20 6f 66 20 61 6e | 0a 6f 62 6a 65 63 74 2e |on of an|.object.|
|00004ab0| 20 20 46 6f 72 20 73 74 | 72 69 6e 67 73 2c 20 74 | For st|rings, t|
|00004ac0| 68 69 73 20 72 65 74 75 | 72 6e 73 20 74 68 65 20 |his retu|rns the |
|00004ad0| 73 74 72 69 6e 67 20 69 | 74 73 65 6c 66 2e 20 20 |string i|tself. |
|00004ae0| 54 68 65 20 64 69 66 66 | 65 72 65 6e 63 65 0a 77 |The diff|erence.w|
|00004af0| 69 74 68 20 5c 63 6f 64 | 65 7b 72 65 70 72 28 5c |ith \cod|e{repr(\|
|00004b00| 76 61 72 7b 6f 62 6a 65 | 63 74 7d 29 7d 20 69 73 |var{obje|ct})} is|
|00004b10| 20 74 68 61 74 20 5c 63 | 6f 64 65 7b 73 74 72 28 | that \c|ode{str(|
|00004b20| 5c 76 61 72 7b 6f 62 6a | 65 63 74 7d 29 7d 20 64 |\var{obj|ect})} d|
|00004b30| 6f 65 73 20 6e 6f 74 0a | 61 6c 77 61 79 73 20 61 |oes not.|always a|
|00004b40| 74 74 65 6d 70 74 20 74 | 6f 20 72 65 74 75 72 6e |ttempt t|o return|
|00004b50| 20 61 20 73 74 72 69 6e | 67 20 74 68 61 74 20 69 | a strin|g that i|
|00004b60| 73 20 61 63 63 65 70 74 | 61 62 6c 65 20 74 6f 20 |s accept|able to |
|00004b70| 5c 63 6f 64 65 7b 65 76 | 61 6c 28 29 7d 3b 0a 69 |\code{ev|al()};.i|
|00004b80| 74 73 20 67 6f 61 6c 20 | 69 73 20 74 6f 20 72 65 |ts goal |is to re|
|00004b90| 74 75 72 6e 20 61 20 70 | 72 69 6e 74 61 62 6c 65 |turn a p|rintable|
|00004ba0| 20 73 74 72 69 6e 67 2e | 0a 5c 65 6e 64 7b 66 75 | string.|.\end{fu|
|00004bb0| 6e 63 64 65 73 63 7d 0a | 0a 5c 62 65 67 69 6e 7b |ncdesc}.|.\begin{|
|00004bc0| 66 75 6e 63 64 65 73 63 | 7d 7b 74 75 70 6c 65 7d |funcdesc|}{tuple}|
|00004bd0| 7b 73 65 71 75 65 6e 63 | 65 7d 0a 52 65 74 75 72 |{sequenc|e}.Retur|
|00004be0| 6e 20 61 20 74 75 70 6c | 65 20 77 68 6f 73 65 20 |n a tupl|e whose |
|00004bf0| 69 74 65 6d 73 20 61 72 | 65 20 74 68 65 20 73 61 |items ar|e the sa|
|00004c00| 6d 65 20 61 6e 64 20 69 | 6e 20 74 68 65 20 73 61 |me and i|n the sa|
|00004c10| 6d 65 20 6f 72 64 65 72 | 20 61 73 0a 5c 76 61 72 |me order| as.\var|
|00004c20| 7b 73 65 71 75 65 6e 63 | 65 7d 27 73 20 69 74 65 |{sequenc|e}'s ite|
|00004c30| 6d 73 2e 20 20 49 66 20 | 5c 76 61 72 7b 73 65 71 |ms. If |\var{seq|
|00004c40| 75 65 6e 63 65 7d 20 69 | 73 20 61 6c 72 65 61 64 |uence} i|s alread|
|00004c50| 20 61 20 74 75 70 6c 65 | 2c 20 69 74 0a 69 73 20 | a tuple|, it.is |
|00004c60| 72 65 74 75 72 6e 65 64 | 20 75 6e 63 68 61 6e 67 |returned| unchang|
|00004c70| 65 64 2e 20 20 46 6f 72 | 20 69 6e 73 74 61 6e 63 |ed. For| instanc|
|00004c80| 65 2c 20 5c 63 6f 64 65 | 7b 74 75 70 6c 65 28 27 |e, \code|{tuple('|
|00004c90| 61 62 63 27 29 7d 20 72 | 65 74 75 72 6e 73 0a 72 |abc')} r|eturns.r|
|00004ca0| 65 74 75 72 6e 73 20 5c | 63 6f 64 65 7b 28 27 61 |eturns \|code{('a|
|00004cb0| 27 2c 20 27 62 27 2c 20 | 27 63 27 29 7d 20 61 6e |', 'b', |'c')} an|
|00004cc0| 64 20 5c 63 6f 64 65 7b | 74 75 70 6c 65 28 5b 31 |d \code{|tuple([1|
|00004cd0| 2c 20 32 2c 20 33 5d 29 | 7d 20 72 65 74 75 72 6e |, 2, 3])|} return|
|00004ce0| 73 0a 5c 63 6f 64 65 7b | 28 31 2c 20 32 2c 20 33 |s.\code{|(1, 2, 3|
|00004cf0| 29 7d 2e 0a 5c 65 6e 64 | 7b 66 75 6e 63 64 65 73 |)}..\end|{funcdes|
|00004d00| 63 7d 0a 0a 5c 62 65 67 | 69 6e 7b 66 75 6e 63 64 |c}..\beg|in{funcd|
|00004d10| 65 73 63 7d 7b 74 79 70 | 65 7d 7b 6f 62 6a 65 63 |esc}{typ|e}{objec|
|00004d20| 74 7d 0a 52 65 74 75 72 | 6e 20 74 68 65 20 74 79 |t}.Retur|n the ty|
|00004d30| 70 65 20 6f 66 20 61 6e | 20 5c 76 61 72 7b 6f 62 |pe of an| \var{ob|
|00004d40| 6a 65 63 74 7d 2e 20 20 | 54 68 65 20 72 65 74 75 |ject}. |The retu|
|00004d50| 72 6e 20 76 61 6c 75 65 | 20 69 73 20 61 20 74 79 |rn value| is a ty|
|00004d60| 70 65 0a 6f 62 6a 65 63 | 74 2e 20 20 54 68 65 20 |pe.objec|t. The |
|00004d70| 73 74 61 6e 64 61 72 64 | 20 6d 6f 64 75 6c 65 20 |standard| module |
|00004d80| 5c 63 6f 64 65 7b 74 79 | 70 65 73 7d 20 64 65 66 |\code{ty|pes} def|
|00004d90| 69 6e 65 73 20 6e 61 6d | 65 73 20 66 6f 72 20 61 |ines nam|es for a|
|00004da0| 6c 6c 0a 62 75 69 6c 74 | 2d 69 6e 20 74 79 70 65 |ll.built|-in type|
|00004db0| 73 2e 0a 5c 73 74 6d 6f | 64 69 6e 64 65 78 7b 74 |s..\stmo|dindex{t|
|00004dc0| 79 70 65 73 7d 0a 5c 6f | 62 69 6e 64 65 78 7b 74 |ypes}.\o|bindex{t|
|00004dd0| 79 70 65 7d 0a 46 6f 72 | 20 69 6e 73 74 61 6e 63 |ype}.For| instanc|
|00004de0| 65 3a 0a 0a 5c 62 63 6f | 64 65 5c 62 65 67 69 6e |e:..\bco|de\begin|
|00004df0| 7b 76 65 72 62 61 74 69 | 6d 7d 0a 3e 3e 3e 20 69 |{verbati|m}.>>> i|
|00004e00| 6d 70 6f 72 74 20 74 79 | 70 65 73 0a 3e 3e 3e 20 |mport ty|pes.>>> |
|00004e10| 69 66 20 74 79 70 65 28 | 78 29 20 3d 3d 20 74 79 |if type(|x) == ty|
|00004e20| 70 65 73 2e 53 74 72 69 | 6e 67 54 79 70 65 3a 20 |pes.Stri|ngType: |
|00004e30| 70 72 69 6e 74 20 22 49 | 74 27 73 20 61 20 73 74 |print "I|t's a st|
|00004e40| 72 69 6e 67 22 0a 5c 65 | 6e 64 7b 76 65 72 62 61 |ring".\e|nd{verba|
|00004e50| 74 69 6d 7d 5c 65 63 6f | 64 65 0a 5c 65 6e 64 7b |tim}\eco|de.\end{|
|00004e60| 66 75 6e 63 64 65 73 63 | 7d 0a 0a 5c 62 65 67 69 |funcdesc|}..\begi|
|00004e70| 6e 7b 66 75 6e 63 64 65 | 73 63 7d 7b 76 61 72 73 |n{funcde|sc}{vars|
|00004e80| 7d 7b 5c 6f 70 74 69 6f | 6e 61 6c 7b 6f 62 6a 65 |}{\optio|nal{obje|
|00004e90| 63 74 7d 7d 0a 57 69 74 | 68 6f 75 74 20 61 72 67 |ct}}.Wit|hout arg|
|00004ea0| 75 6d 65 6e 74 73 2c 20 | 72 65 74 75 72 6e 20 61 |uments, |return a|
|00004eb0| 20 64 69 63 74 69 6f 6e | 61 72 79 20 63 6f 72 72 | diction|ary corr|
|00004ec0| 65 73 70 6f 6e 64 69 6e | 67 20 74 6f 20 74 68 65 |espondin|g to the|
|00004ed0| 20 63 75 72 72 65 6e 74 | 0a 6c 6f 63 61 6c 20 73 | current|.local s|
|00004ee0| 79 6d 62 6f 6c 20 74 61 | 62 6c 65 2e 20 20 57 69 |ymbol ta|ble. Wi|
|00004ef0| 74 68 20 61 20 6d 6f 64 | 75 6c 65 2c 20 63 6c 61 |th a mod|ule, cla|
|00004f00| 73 73 20 6f 72 20 63 6c | 61 73 73 20 69 6e 73 74 |ss or cl|ass inst|
|00004f10| 61 6e 63 65 20 6f 62 6a | 65 63 74 20 61 73 0a 61 |ance obj|ect as.a|
|00004f20| 72 67 75 6d 65 6e 74 20 | 28 6f 72 20 61 6e 79 74 |rgument |(or anyt|
|00004f30| 68 69 6e 67 20 65 6c 73 | 65 20 74 68 61 74 20 68 |hing els|e that h|
|00004f40| 61 73 20 61 20 5c 63 6f | 64 65 7b 5f 5f 64 69 63 |as a \co|de{__dic|
|00004f50| 74 5f 5f 7d 20 61 74 74 | 72 69 62 75 74 65 29 2c |t__} att|ribute),|
|00004f60| 0a 72 65 74 75 72 6e 73 | 20 61 20 64 69 63 74 69 |.returns| a dicti|
|00004f70| 6f 6e 61 72 79 20 63 6f | 72 72 65 73 70 6f 6e 64 |onary co|rrespond|
|00004f80| 69 6e 67 20 74 6f 20 74 | 68 65 20 6f 62 6a 65 63 |ing to t|he objec|
|00004f90| 74 27 73 20 73 79 6d 62 | 6f 6c 20 74 61 62 6c 65 |t's symb|ol table|
|00004fa0| 2e 0a 54 68 65 20 72 65 | 74 75 72 6e 65 64 20 64 |..The re|turned d|
|00004fb0| 69 63 74 69 6f 6e 61 72 | 79 20 73 68 6f 75 6c 64 |ictionar|y should|
|00004fc0| 20 6e 6f 74 20 62 65 20 | 6d 6f 64 69 66 69 65 64 | not be |modified|
|00004fd0| 3a 20 74 68 65 20 65 66 | 66 65 63 74 73 20 6f 6e |: the ef|fects on|
|00004fe0| 20 74 68 65 0a 63 6f 72 | 72 65 73 70 6f 6e 64 69 | the.cor|respondi|
|00004ff0| 6e 67 20 73 79 6d 62 6f | 6c 20 74 61 62 6c 65 20 |ng symbo|l table |
|00005000| 61 72 65 20 75 6e 64 65 | 66 69 6e 65 64 2e 25 0a |are unde|fined.%.|
|00005010| 5c 66 6f 6f 74 6e 6f 74 | 65 7b 49 6e 20 74 68 65 |\footnot|e{In the|
|00005020| 20 63 75 72 72 65 6e 74 | 20 69 6d 70 6c 65 6d 65 | current| impleme|
|00005030| 6e 74 61 74 69 6f 6e 2c | 20 6c 6f 63 61 6c 20 76 |ntation,| local v|
|00005040| 61 72 69 61 62 6c 65 20 | 62 69 6e 64 69 6e 67 73 |ariable |bindings|
|00005050| 0a 63 61 6e 6e 6f 74 20 | 6e 6f 72 6d 61 6c 6c 79 |.cannot |normally|
|00005060| 20 62 65 20 61 66 66 65 | 63 74 65 64 20 74 68 69 | be affe|cted thi|
|00005070| 73 20 77 61 79 2c 20 62 | 75 74 20 76 61 72 69 61 |s way, b|ut varia|
|00005080| 62 6c 65 73 20 72 65 74 | 72 69 65 76 65 64 20 66 |bles ret|rieved f|
|00005090| 72 6f 6d 0a 6f 74 68 65 | 72 20 73 63 6f 70 65 73 |rom.othe|r scopes|
|000050a0| 20 28 65 2e 67 2e 20 6d | 6f 64 75 6c 65 73 29 20 | (e.g. m|odules) |
|000050b0| 63 61 6e 20 62 65 2e 20 | 20 54 68 69 73 20 6d 61 |can be. | This ma|
|000050c0| 79 20 63 68 61 6e 67 65 | 2e 7d 0a 5c 65 6e 64 7b |y change|.}.\end{|
|000050d0| 66 75 6e 63 64 65 73 63 | 7d 0a 0a 5c 62 65 67 69 |funcdesc|}..\begi|
|000050e0| 6e 7b 66 75 6e 63 64 65 | 73 63 7d 7b 78 72 61 6e |n{funcde|sc}{xran|
|000050f0| 67 65 7d 7b 5c 6f 70 74 | 69 6f 6e 61 6c 7b 73 74 |ge}{\opt|ional{st|
|00005100| 61 72 74 5c 2c 7d 20 65 | 6e 64 5c 6f 70 74 69 6f |art\,} e|nd\optio|
|00005110| 6e 61 6c 7b 5c 2c 20 73 | 74 65 70 7d 7d 0a 54 68 |nal{\, s|tep}}.Th|
|00005120| 69 73 20 66 75 6e 63 74 | 69 6f 6e 20 69 73 20 76 |is funct|ion is v|
|00005130| 65 72 79 20 73 69 6d 69 | 6c 61 72 20 74 6f 20 5c |ery simi|lar to \|
|00005140| 63 6f 64 65 7b 72 61 6e | 67 65 28 29 7d 2c 20 62 |code{ran|ge()}, b|
|00005150| 75 74 20 72 65 74 75 72 | 6e 73 20 61 6e 0a 60 60 |ut retur|ns an.``|
|00005160| 78 72 61 6e 67 65 20 6f | 62 6a 65 63 74 27 27 20 |xrange o|bject'' |
|00005170| 69 6e 73 74 65 61 64 20 | 6f 66 20 61 20 6c 69 73 |instead |of a lis|
|00005180| 74 2e 20 20 54 68 69 73 | 20 69 73 20 61 6e 20 6f |t. This| is an o|
|00005190| 70 61 71 75 65 20 73 65 | 71 75 65 6e 63 65 20 74 |paque se|quence t|
|000051a0| 79 70 65 0a 77 68 69 63 | 68 20 79 69 65 6c 64 73 |ype.whic|h yields|
|000051b0| 20 74 68 65 20 73 61 6d | 65 20 76 61 6c 75 65 73 | the sam|e values|
|000051c0| 20 61 73 20 74 68 65 20 | 63 6f 72 72 65 73 70 6f | as the |correspo|
|000051d0| 6e 64 69 6e 67 20 6c 69 | 73 74 2c 20 77 69 74 68 |nding li|st, with|
|000051e0| 6f 75 74 0a 61 63 74 75 | 61 6c 6c 79 20 73 74 6f |out.actu|ally sto|
|000051f0| 72 69 6e 67 20 74 68 65 | 6d 20 61 6c 6c 20 73 69 |ring the|m all si|
|00005200| 6d 75 6c 74 61 6e 65 6f | 75 73 6c 79 2e 20 20 54 |multaneo|usly. T|
|00005210| 68 65 20 61 64 76 61 6e | 74 61 67 65 20 6f 66 0a |he advan|tage of.|
|00005220| 5c 63 6f 64 65 7b 78 72 | 61 6e 67 65 28 29 7d 20 |\code{xr|ange()} |
|00005230| 6f 76 65 72 20 5c 63 6f | 64 65 7b 72 61 6e 67 65 |over \co|de{range|
|00005240| 28 29 7d 20 69 73 20 6d | 69 6e 69 6d 61 6c 20 28 |()} is m|inimal (|
|00005250| 73 69 6e 63 65 20 5c 63 | 6f 64 65 7b 78 72 61 6e |since \c|ode{xran|
|00005260| 67 65 28 29 7d 0a 73 74 | 69 6c 6c 20 68 61 73 20 |ge()}.st|ill has |
|00005270| 74 6f 20 63 72 65 61 74 | 65 20 74 68 65 20 76 61 |to creat|e the va|
|00005280| 6c 75 65 73 20 77 68 65 | 6e 20 61 73 6b 65 64 20 |lues whe|n asked |
|00005290| 66 6f 72 20 74 68 65 6d | 29 20 65 78 63 65 70 74 |for them|) except|
|000052a0| 20 77 68 65 6e 20 61 20 | 76 65 72 79 0a 6c 61 72 | when a |very.lar|
|000052b0| 67 65 20 72 61 6e 67 65 | 20 69 73 20 75 73 65 64 |ge range| is used|
|000052c0| 20 6f 6e 20 61 20 6d 65 | 6d 6f 72 79 2d 73 74 61 | on a me|mory-sta|
|000052d0| 72 76 65 64 20 6d 61 63 | 68 69 6e 65 20 28 65 2e |rved mac|hine (e.|
|000052e0| 67 2e 20 4d 53 2d 44 4f | 53 29 20 6f 72 20 77 68 |g. MS-DO|S) or wh|
|000052f0| 65 6e 20 61 6c 6c 0a 6f | 66 20 74 68 65 20 72 61 |en all.o|f the ra|
|00005300| 6e 67 65 27 73 20 65 6c | 65 6d 65 6e 74 73 20 61 |nge's el|ements a|
|00005310| 72 65 20 6e 65 76 65 72 | 20 75 73 65 64 20 28 65 |re never| used (e|
|00005320| 2e 67 2e 20 77 68 65 6e | 20 74 68 65 20 6c 6f 6f |.g. when| the loo|
|00005330| 70 20 69 73 20 75 73 75 | 61 6c 6c 79 0a 74 65 72 |p is usu|ally.ter|
|00005340| 6d 69 6e 61 74 65 64 20 | 77 69 74 68 20 5c 63 6f |minated |with \co|
|00005350| 64 65 7b 62 72 65 61 6b | 7d 29 2e 0a 5c 65 6e 64 |de{break|})..\end|
|00005360| 7b 66 75 6e 63 64 65 73 | 63 7d 0a |{funcdes|c}. |
+--------+-------------------------+-------------------------+--------+--------+