home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / OPENSTEP / Languages / Python / python-14-src / Doc / libpyrl.tex < prev    next >
LaTeX Document  |  1997-01-17  |  2.4 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: LaTeX Document (document/latex).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert LaTeX Document (document/latex) magic Supported
1% dexvert Corel 10 Texture (image/corel10Texture) ext Unsupported
1% dexvert Croteam texture file (image/croteamTextureFile) ext Unsupported
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% 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 4d 6f 64 75 6c 65 | 20 5c 73 65 63 74 63 6f |n Module| \sectco|
|00000020| 64 65 7b 70 79 72 6c 7d | 7d 0a 5c 62 69 6d 6f 64 |de{pyrl}|}.\bimod|
|00000030| 69 6e 64 65 78 7b 70 79 | 72 6c 7d 0a 5c 72 65 6e |index{py|rl}.\ren|
|00000040| 65 77 63 6f 6d 6d 61 6e | 64 7b 5c 69 6e 64 65 78 |ewcomman|d{\index|
|00000050| 73 75 62 69 74 65 6d 7d | 7b 28 69 6e 20 6d 6f 64 |subitem}|{(in mod|
|00000060| 75 6c 65 20 70 79 72 6c | 29 7d 0a 0a 54 68 65 20 |ule pyrl|)}..The |
|00000070| 5c 63 6f 64 65 7b 70 79 | 72 6c 7d 20 6d 6f 64 75 |\code{py|rl} modu|
|00000080| 6c 65 20 70 6c 75 67 69 | 6e 73 20 74 68 65 20 5c |le plugi|ns the \|
|00000090| 64 66 6e 7b 47 4e 55 20 | 72 65 61 64 6c 69 6e 65 |dfn{GNU |readline|
|000000a0| 7d 20 66 61 63 69 6c 69 | 74 69 65 73 20 69 6e 74 |} facili|ties int|
|000000b0| 6f 0a 74 68 65 20 69 6e | 74 65 72 70 72 65 74 65 |o.the in|terprete|
|000000c0| 72 20 77 68 65 6e 20 69 | 74 20 72 75 6e 73 20 69 |r when i|t runs i|
|000000d0| 6e 20 69 6e 74 65 72 61 | 63 74 69 76 65 20 6d 6f |n intera|ctive mo|
|000000e0| 64 65 2e 20 59 6f 75 20 | 64 6f 20 6e 6f 74 20 6e |de. You |do not n|
|000000f0| 65 65 64 20 74 6f 0a 69 | 6d 70 6f 72 74 20 74 68 |eed to.i|mport th|
|00000100| 69 73 20 6d 6f 64 75 6c | 65 2c 20 61 73 20 74 68 |is modul|e, as th|
|00000110| 69 73 20 69 73 20 64 6f | 6e 65 20 61 75 74 6f 6d |is is do|ne autom|
|00000120| 61 74 69 63 61 6c 6c 79 | 20 77 68 65 6e 65 76 65 |atically| wheneve|
|00000130| 72 20 74 68 65 0a 69 6e | 74 65 72 70 72 65 74 65 |r the.in|terprete|
|00000140| 72 20 67 6f 65 73 20 69 | 6e 20 69 6e 74 65 72 61 |r goes i|n intera|
|00000150| 63 74 69 76 65 20 6d 6f | 64 65 2e 20 59 6f 75 20 |ctive mo|de. You |
|00000160| 6d 61 79 20 6e 65 65 64 | 20 74 6f 20 64 6f 20 69 |may need| to do i|
|00000170| 74 20 65 78 70 6c 69 63 | 69 74 6c 79 0a 69 66 20 |t explic|itly.if |
|00000180| 79 6f 75 20 77 61 6e 74 | 20 74 6f 20 75 73 65 20 |you want| to use |
|00000190| 69 74 73 20 66 75 6e 63 | 74 69 6f 6e 61 6c 69 74 |its func|tionalit|
|000001a0| 69 65 73 20 69 6e 20 79 | 6f 75 72 20 6f 77 6e 20 |ies in y|our own |
|000001b0| 73 63 72 69 70 74 73 2e | 0a 0a 50 75 74 74 69 6e |scripts.|..Puttin|
|000001c0| 67 20 74 68 65 20 72 65 | 61 64 6c 69 6e 65 20 66 |g the re|adline f|
|000001d0| 61 63 69 6c 69 74 79 20 | 69 6e 20 69 74 73 20 6f |acility |in its o|
|000001e0| 77 6e 20 6d 6f 64 75 6c | 65 20 68 61 73 20 73 65 |wn modul|e has se|
|000001f0| 76 65 72 61 6c 0a 61 64 | 76 61 6e 74 61 67 65 73 |veral.ad|vantages|
|00000200| 3a 20 69 66 20 79 6f 75 | 20 63 61 6e 20 62 75 69 |: if you| can bui|
|00000210| 6c 64 20 69 74 20 61 73 | 20 61 20 73 68 61 72 65 |ld it as| a share|
|00000220| 64 20 6d 6f 64 75 6c 65 | 2c 20 69 74 20 77 69 6c |d module|, it wil|
|00000230| 6c 20 73 61 76 65 0a 68 | 75 6e 64 72 65 64 73 20 |l save.h|undreds |
|00000240| 6f 66 20 6b 69 6c 6f 62 | 79 74 65 73 20 69 6e 20 |of kilob|ytes in |
|00000250| 74 68 65 20 63 6f 72 65 | 20 69 6e 74 65 72 70 72 |the core| interpr|
|00000260| 65 74 65 72 20 62 69 6e | 61 72 79 20 69 6d 61 67 |eter bin|ary imag|
|00000270| 65 2c 20 61 73 20 69 74 | 20 77 69 6c 6c 0a 62 65 |e, as it| will.be|
|00000280| 20 6c 6f 61 64 65 64 20 | 6f 6e 6c 79 20 77 68 65 | loaded |only whe|
|00000290| 6e 20 79 6f 75 20 65 78 | 65 63 75 74 65 20 50 79 |n you ex|ecute Py|
|000002a0| 74 68 6f 6e 20 69 6e 20 | 69 6e 74 65 72 61 63 74 |thon in |interact|
|000002b0| 69 76 65 20 6d 6f 64 65 | 3b 20 73 69 6e 63 65 20 |ive mode|; since |
|000002c0| 74 68 65 0a 47 4e 55 20 | 72 65 61 64 6c 69 6e 65 |the.GNU |readline|
|000002d0| 20 6d 61 79 20 62 65 20 | 63 6f 6e 66 69 67 75 72 | may be |configur|
|000002e0| 65 64 20 74 6f 20 66 69 | 74 73 20 79 6f 75 72 20 |ed to fi|ts your |
|000002f0| 6e 65 65 64 73 2c 20 74 | 68 65 20 6d 6f 64 75 6c |needs, t|he modul|
|00000300| 65 20 70 72 6f 76 69 64 | 65 73 0a 68 6f 6f 6b 73 |e provid|es.hooks|
|00000310| 20 74 6f 20 6d 6f 64 69 | 66 79 20 69 74 73 20 62 | to modi|fy its b|
|00000320| 65 68 61 76 69 6f 75 72 | 20 69 6e 20 61 6e 20 65 |ehaviour| in an e|
|00000330| 61 73 79 20 61 6e 64 20 | 70 79 74 68 6f 6e 69 63 |asy and |pythonic|
|00000340| 20 77 61 79 2e 0a 0a 42 | 65 63 61 75 73 65 20 74 | way...B|ecause t|
|00000350| 68 65 20 6d 6f 64 75 6c | 65 20 72 65 71 75 69 72 |he modul|e requir|
|00000360| 65 73 20 61 20 70 61 74 | 63 68 65 64 20 50 79 74 |es a pat|ched Pyt|
|00000370| 68 6f 6e 20 69 6e 74 65 | 72 70 72 65 74 65 72 2c |hon inte|rpreter,|
|00000380| 20 69 74 27 73 0a 61 76 | 61 69 6c 61 62 6c 65 20 | it's.av|ailable |
|00000390| 73 65 70 61 72 61 74 65 | 6c 79 2e 0a 0a 54 68 65 |separate|ly...The|
|000003a0| 20 5c 63 6f 64 65 7b 70 | 79 72 6c 7d 20 6d 6f 64 | \code{p|yrl} mod|
|000003b0| 75 6c 65 20 64 65 66 69 | 6e 65 73 20 74 68 65 20 |ule defi|nes the |
|000003c0| 66 6f 6c 6c 6f 77 69 6e | 67 20 66 75 6e 63 74 69 |followin|g functi|
|000003d0| 6f 6e 73 3a 0a 0a 5c 62 | 65 67 69 6e 7b 66 75 6e |ons:..\b|egin{fun|
|000003e0| 63 64 65 73 63 7d 7b 73 | 65 74 5f 63 6f 6d 70 6c |cdesc}{s|et_compl|
|000003f0| 65 74 65 72 7d 7b 63 61 | 6c 6c 61 62 6c 65 2d 6f |eter}{ca|llable-o|
|00000400| 62 6a 65 63 74 7d 0a 52 | 65 70 6c 61 63 65 73 20 |bject}.R|eplaces |
|00000410| 74 68 65 20 62 75 69 6c | 74 69 6e 20 63 6f 6d 70 |the buil|tin comp|
|00000420| 6c 65 74 65 72 20 66 75 | 6e 63 74 69 6f 6e 20 77 |leter fu|nction w|
|00000430| 69 74 68 0a 5c 76 61 72 | 7b 63 61 6c 6c 61 62 6c |ith.\var|{callabl|
|00000440| 65 2d 6f 62 6a 65 63 74 | 7d 2e 20 54 68 69 73 20 |e-object|}. This |
|00000450| 66 75 6e 63 74 69 6f 6e | 20 67 65 74 73 20 63 61 |function| gets ca|
|00000460| 6c 6c 65 64 20 77 68 65 | 6e 65 76 65 72 20 74 68 |lled whe|never th|
|00000470| 65 20 75 73 65 72 0a 68 | 69 74 73 20 5c 63 6f 64 |e user.h|its \cod|
|00000480| 65 7b 4d 2d 54 61 62 7d | 20 28 6f 72 20 5c 63 6f |e{M-Tab}| (or \co|
|00000490| 64 65 7b 45 53 43 2d 54 | 61 62 7d 29 3a 20 69 74 |de{ESC-T|ab}): it|
|000004a0| 20 72 65 63 65 69 76 65 | 73 20 74 68 72 65 65 20 | receive|s three |
|000004b0| 61 72 67 75 6d 65 6e 74 | 73 2c 0a 74 68 65 20 5c |argument|s,.the \|
|000004c0| 76 61 72 7b 54 45 58 54 | 7d 20 65 6e 74 65 72 65 |var{TEXT|} entere|
|000004d0| 64 20 73 6f 20 66 61 72 | 2c 20 5c 76 61 72 7b 53 |d so far|, \var{S|
|000004e0| 54 41 52 54 7d 20 61 6e | 64 20 5c 76 61 72 7b 45 |TART} an|d \var{E|
|000004f0| 4e 44 7d 20 64 65 6c 69 | 6d 69 74 20 74 68 65 0a |ND} deli|mit the.|
|00000500| 72 65 67 69 6f 6e 20 6f | 66 20 5c 76 61 72 7b 54 |region o|f \var{T|
|00000510| 45 58 54 7d 20 74 68 61 | 74 20 63 6f 6e 74 61 69 |EXT} tha|t contai|
|00000520| 6e 73 20 74 68 65 20 77 | 6f 72 64 20 74 6f 20 63 |ns the w|ord to c|
|00000530| 6f 6d 70 6c 65 74 65 2e | 20 49 74 20 73 68 6f 75 |omplete.| It shou|
|00000540| 6c 64 0a 72 65 74 75 72 | 6e 20 74 68 65 20 6c 69 |ld.retur|n the li|
|00000550| 73 74 20 6f 66 20 74 68 | 65 20 70 6f 73 73 69 62 |st of th|e possib|
|00000560| 6c 65 20 63 6f 6d 70 6c | 65 74 69 6f 6e 73 20 66 |le compl|etions f|
|00000570| 6f 72 20 5c 76 61 72 7b | 54 45 58 54 7d 2c 20 6f |or \var{|TEXT}, o|
|00000580| 72 20 4e 6f 6e 65 2e 0a | 0a 50 61 73 73 69 6e 67 |r None..|.Passing|
|00000590| 20 4e 6f 6e 65 20 61 73 | 20 5c 76 61 72 7b 63 61 | None as| \var{ca|
|000005a0| 6c 6c 61 62 6c 65 2d 6f | 62 6a 65 63 74 7d 20 72 |llable-o|bject} r|
|000005b0| 65 73 74 6f 72 65 73 20 | 74 68 65 20 62 75 69 6c |estores |the buil|
|000005c0| 74 69 6e 20 63 6f 6d 70 | 6c 65 74 65 72 2e 0a 0a |tin comp|leter...|
|000005d0| 49 74 20 72 65 74 75 72 | 6e 73 20 74 68 65 20 6f |It retur|ns the o|
|000005e0| 6c 64 20 63 6f 6d 70 6c | 65 74 65 72 20 6f 62 6a |ld compl|eter obj|
|000005f0| 65 63 74 2c 20 6f 72 20 | 4e 6f 6e 65 20 69 66 20 |ect, or |None if |
|00000600| 69 74 20 77 61 73 20 74 | 68 65 20 62 75 69 6c 74 |it was t|he built|
|00000610| 69 6e 0a 6f 6e 65 2e 0a | 5c 65 6e 64 7b 66 75 6e |in.one..|\end{fun|
|00000620| 63 64 65 73 63 7d 0a 0a | 5c 62 65 67 69 6e 7b 66 |cdesc}..|\begin{f|
|00000630| 75 6e 63 64 65 73 63 7d | 7b 62 75 69 6c 74 69 6e |uncdesc}|{builtin|
|00000640| 5f 63 6f 6d 70 6c 65 74 | 65 72 7d 7b 74 65 78 74 |_complet|er}{text|
|00000650| 2c 20 73 74 61 72 74 2c | 20 65 6e 64 7d 0a 54 68 |, start,| end}.Th|
|00000660| 69 73 20 69 73 20 74 68 | 65 20 62 75 69 6c 74 69 |is is th|e builti|
|00000670| 6e 20 63 6f 6d 70 6c 65 | 74 65 72 20 66 75 6e 63 |n comple|ter func|
|00000680| 74 69 6f 6e 2e 20 59 6f | 75 20 63 61 6e 20 75 73 |tion. Yo|u can us|
|00000690| 65 20 69 74 20 66 72 6f | 6d 0a 79 6f 75 72 20 6f |e it fro|m.your o|
|000006a0| 77 6e 20 63 6f 6d 70 6c | 65 74 65 72 20 66 75 6e |wn compl|eter fun|
|000006b0| 63 74 69 6f 6e 2e 20 49 | 74 20 72 65 74 75 72 6e |ction. I|t return|
|000006c0| 73 20 74 68 65 20 6c 69 | 73 74 20 63 6f 6e 74 61 |s the li|st conta|
|000006d0| 69 6e 69 6e 67 20 74 68 | 65 0a 63 6f 6d 70 6c 65 |ining th|e.comple|
|000006e0| 74 69 6f 6e 73 2c 20 6f | 72 20 4e 6f 6e 65 20 69 |tions, o|r None i|
|000006f0| 66 20 74 68 65 72 65 20 | 69 73 20 6e 6f 20 70 6f |f there |is no po|
|00000700| 73 73 69 62 6c 65 20 63 | 6f 6d 70 6c 65 74 69 6f |ssible c|ompletio|
|00000710| 6e 2e 0a 5c 65 6e 64 7b | 66 75 6e 63 64 65 73 63 |n..\end{|funcdesc|
|00000720| 7d 0a 0a 5c 62 65 67 69 | 6e 7b 66 75 6e 63 64 65 |}..\begi|n{funcde|
|00000730| 73 63 7d 7b 72 65 61 64 | 6c 69 6e 65 7d 7b 5c 6f |sc}{read|line}{\o|
|00000740| 70 74 69 6f 6e 61 6c 7b | 70 72 6f 6d 70 74 7d 7d |ptional{|prompt}}|
|00000750| 0a 52 65 61 64 73 20 61 | 20 6c 69 6e 65 20 6f 66 |.Reads a| line of|
|00000760| 20 75 73 65 72 20 69 6e | 70 75 74 20 75 73 69 6e | user in|put usin|
|00000770| 67 20 74 68 65 20 47 4e | 55 20 72 65 61 64 6c 69 |g the GN|U readli|
|00000780| 6e 65 20 66 61 63 69 6c | 69 74 69 65 73 2e 20 52 |ne facil|ities. R|
|00000790| 65 74 75 72 6e 73 0a 61 | 20 73 74 72 69 6e 67 20 |eturns.a| string |
|000007a0| 6f 62 6a 65 63 74 2e 0a | 5c 65 6e 64 7b 66 75 6e |object..|\end{fun|
|000007b0| 63 64 65 73 63 7d 0a 0a | 54 68 65 20 5c 64 66 6e |cdesc}..|The \dfn|
|000007c0| 7b 63 61 6c 6c 61 62 6c | 65 20 6f 62 6a 65 63 74 |{callabl|e object|
|000007d0| 7d 20 79 6f 75 20 70 61 | 73 73 20 74 6f 20 5c 63 |} you pa|ss to \c|
|000007e0| 6f 64 65 7b 73 65 74 5c | 5f 63 6f 6d 70 6c 65 74 |ode{set\|_complet|
|000007f0| 65 72 28 29 7d 20 73 68 | 6f 75 6c 64 0a 72 65 74 |er()} sh|ould.ret|
|00000800| 75 72 6e 20 61 20 6c 69 | 73 74 20 63 6f 6e 74 61 |urn a li|st conta|
|00000810| 69 6e 69 6e 67 20 74 68 | 65 20 70 6f 73 73 69 62 |ining th|e possib|
|00000820| 6c 65 20 63 6f 6d 70 6c | 65 74 69 6f 6e 20 66 6f |le compl|etion fo|
|00000830| 72 20 5c 76 61 72 7b 54 | 45 58 54 7d 2e 0a 0a 5c |r \var{T|EXT}...\|
|00000840| 62 65 67 69 6e 7b 76 65 | 72 62 61 74 69 6d 7d 0a |begin{ve|rbatim}.|
|00000850| 3e 3e 3e 20 64 65 66 20 | 6d 79 5f 63 6f 6d 70 6c |>>> def |my_compl|
|00000860| 65 74 65 72 20 28 74 65 | 78 74 2c 20 73 74 61 72 |eter (te|xt, star|
|00000870| 74 2c 20 65 6e 64 29 3a | 0a 2e 2e 2e 20 20 20 20 |t, end):|.... |
|00000880| 20 66 72 6f 6d 20 70 79 | 72 6c 20 69 6d 70 6f 72 | from py|rl impor|
|00000890| 74 20 62 75 69 6c 74 69 | 6e 5f 63 6f 6d 70 6c 65 |t builti|n_comple|
|000008a0| 74 65 72 0a 2e 2e 2e 20 | 20 20 20 20 70 72 69 6e |ter.... | prin|
|000008b0| 74 20 22 54 65 78 74 3a | 20 25 73 20 73 74 61 72 |t "Text:| %s star|
|000008c0| 74 3a 20 25 64 20 65 6e | 64 3a 20 25 64 22 20 25 |t: %d en|d: %d" %|
|000008d0| 20 28 74 65 78 74 2c 20 | 73 74 61 72 74 2c 20 65 | (text, |start, e|
|000008e0| 6e 64 29 0a 2e 2e 2e 20 | 20 20 20 20 63 6f 6d 70 |nd).... | comp|
|000008f0| 6c 20 3d 20 62 75 69 6c | 74 69 6e 5f 63 6f 6d 70 |l = buil|tin_comp|
|00000900| 6c 65 74 65 72 20 28 74 | 65 78 74 2c 20 73 74 61 |leter (t|ext, sta|
|00000910| 72 74 2c 20 65 6e 64 29 | 0a 2e 2e 2e 20 20 20 20 |rt, end)|.... |
|00000920| 20 70 72 69 6e 74 20 63 | 6f 6d 70 6c 0a 2e 2e 2e | print c|ompl....|
|00000930| 20 20 20 20 20 72 65 74 | 75 72 6e 20 63 6f 6d 70 | ret|urn comp|
|00000940| 6c 0a 2e 2e 2e 0a 3e 3e | 3e 20 70 79 72 6c 2e 73 |l.....>>|> pyrl.s|
|00000950| 65 74 5f 63 6f 6d 70 6c | 65 74 65 72 20 28 6d 79 |et_compl|eter (my|
|00000960| 5f 63 6f 6d 70 6c 65 74 | 65 72 29 0a 3e 3e 3e 20 |_complet|er).>>> |
|00000970| 70 79 20 4d 2d 54 61 62 | 0a 54 65 78 74 3a 20 70 |py M-Tab|.Text: p|
|00000980| 79 20 73 74 61 72 74 3a | 20 30 20 65 6e 64 3a 20 |y start:| 0 end: |
|00000990| 32 0a 5b 27 70 79 72 6c | 27 5d 0a 3e 3e 3e 20 70 |2.['pyrl|'].>>> p|
|000009a0| 79 72 6c 0a 5c 65 6e 64 | 7b 76 65 72 62 61 74 69 |yrl.\end|{verbati|
|000009b0| 6d 7d 0a 0a 0a 0a | |m}.... | |
+--------+-------------------------+-------------------------+--------+--------+