home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Python 1.1 / Doc / libmarshal.tex < prev    next >
LaTeX Document  |  1994-01-02  |  2.5 KB  |  [TEXT/R*ch]

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

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

You can browse this item here: libmarshal.tex

ConfidenceProgramDetectionMatch TypeSupport
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, with CR line terminators default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/281 LaTeX (Subdocument) default
100% detectItEasy Format: plain text[CR] default (weak)


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[R*ch]



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 6d 61 72 73 68 | 61 6c 7d 7d 0d 0d 5c 62 |de{marsh|al}}..\b|
|00000030| 69 6d 6f 64 69 6e 64 65 | 78 7b 6d 61 72 73 68 61 |imodinde|x{marsha|
|00000040| 6c 7d 0d 54 68 69 73 20 | 6d 6f 64 75 6c 65 20 63 |l}.This |module c|
|00000050| 6f 6e 74 61 69 6e 73 20 | 66 75 6e 63 74 69 6f 6e |ontains |function|
|00000060| 73 20 74 68 61 74 20 63 | 61 6e 20 72 65 61 64 20 |s that c|an read |
|00000070| 61 6e 64 20 77 72 69 74 | 65 20 50 79 74 68 6f 6e |and writ|e Python|
|00000080| 0d 76 61 6c 75 65 73 20 | 69 6e 20 61 20 62 69 6e |.values |in a bin|
|00000090| 61 72 79 20 66 6f 72 6d | 61 74 2e 20 20 54 68 65 |ary form|at. The|
|000000a0| 20 66 6f 72 6d 61 74 20 | 69 73 20 73 70 65 63 69 | format |is speci|
|000000b0| 66 69 63 20 74 6f 20 50 | 79 74 68 6f 6e 2c 20 62 |fic to P|ython, b|
|000000c0| 75 74 0d 69 6e 64 65 70 | 65 6e 64 65 6e 74 20 6f |ut.indep|endent o|
|000000d0| 66 20 6d 61 63 68 69 6e | 65 20 61 72 63 68 69 74 |f machin|e archit|
|000000e0| 65 63 74 75 72 65 20 69 | 73 73 75 65 73 20 28 65 |ecture i|ssues (e|
|000000f0| 2e 67 2e 2c 20 79 6f 75 | 20 63 61 6e 20 77 72 69 |.g., you| can wri|
|00000100| 74 65 20 61 0d 50 79 74 | 68 6f 6e 20 76 61 6c 75 |te a.Pyt|hon valu|
|00000110| 65 20 74 6f 20 61 20 66 | 69 6c 65 20 6f 6e 20 61 |e to a f|ile on a|
|00000120| 20 56 41 58 2c 20 74 72 | 61 6e 73 70 6f 72 74 20 | VAX, tr|ansport |
|00000130| 74 68 65 20 66 69 6c 65 | 20 74 6f 20 61 20 4d 61 |the file| to a Ma|
|00000140| 63 2c 20 61 6e 64 20 72 | 65 61 64 0d 69 74 20 62 |c, and r|ead.it b|
|00000150| 61 63 6b 20 74 68 65 72 | 65 29 2e 20 20 44 65 74 |ack ther|e). Det|
|00000160| 61 69 6c 73 20 6f 66 20 | 74 68 65 20 66 6f 72 6d |ails of |the form|
|00000170| 61 74 20 6e 6f 74 20 65 | 78 70 6c 61 69 6e 65 64 |at not e|xplained|
|00000180| 20 68 65 72 65 3b 20 72 | 65 61 64 20 74 68 65 0d | here; r|ead the.|
|00000190| 73 6f 75 72 63 65 20 69 | 66 20 79 6f 75 27 72 65 |source i|f you're|
|000001a0| 20 69 6e 74 65 72 65 73 | 74 65 64 2e 25 0d 5c 66 | interes|ted.%.\f|
|000001b0| 6f 6f 74 6e 6f 74 65 7b | 54 68 65 20 6e 61 6d 65 |ootnote{|The name|
|000001c0| 20 6f 66 20 74 68 69 73 | 20 6d 6f 64 75 6c 65 20 | of this| module |
|000001d0| 73 74 65 6d 73 20 66 72 | 6f 6d 20 61 20 62 69 74 |stems fr|om a bit|
|000001e0| 20 6f 66 20 74 65 72 6d | 69 6e 6f 6c 6f 67 79 20 | of term|inology |
|000001f0| 75 73 65 64 0d 62 79 20 | 74 68 65 20 64 65 73 69 |used.by |the desi|
|00000200| 67 6e 65 72 73 20 6f 66 | 20 4d 6f 64 75 6c 61 2d |gners of| Modula-|
|00000210| 33 20 28 61 6d 6f 6e 67 | 73 74 20 6f 74 68 65 72 |3 (among|st other|
|00000220| 73 29 2c 20 77 68 6f 20 | 75 73 65 20 74 68 65 20 |s), who |use the |
|00000230| 74 65 72 6d 0d 60 60 6d | 61 72 73 68 61 6c 6c 69 |term.``m|arshalli|
|00000240| 6e 67 27 27 20 66 6f 72 | 20 73 68 69 70 70 69 6e |ng'' for| shippin|
|00000250| 67 20 6f 66 20 64 61 74 | 61 20 61 72 6f 75 6e 64 |g of dat|a around|
|00000260| 20 69 6e 20 61 20 73 65 | 6c 66 2d 63 6f 6e 74 61 | in a se|lf-conta|
|00000270| 69 6e 65 64 20 66 6f 72 | 6d 2e 0d 53 74 72 69 63 |ined for|m..Stric|
|00000280| 74 6c 79 20 73 70 65 61 | 6b 69 6e 67 2c 20 60 60 |tly spea|king, ``|
|00000290| 74 6f 20 6d 61 72 73 68 | 61 6c 27 27 20 6d 65 61 |to marsh|al'' mea|
|000002a0| 6e 73 20 74 6f 20 63 6f | 6e 76 65 72 74 20 73 6f |ns to co|nvert so|
|000002b0| 6d 65 20 64 61 74 61 20 | 66 72 6f 6d 0d 69 6e 74 |me data |from.int|
|000002c0| 65 72 6e 61 6c 20 74 6f | 20 65 78 74 65 72 6e 61 |ernal to| externa|
|000002d0| 6c 20 66 6f 72 6d 20 28 | 69 6e 20 61 6e 20 52 50 |l form (|in an RP|
|000002e0| 43 20 62 75 66 66 65 72 | 20 66 6f 72 20 69 6e 73 |C buffer| for ins|
|000002f0| 74 61 6e 63 65 29 20 61 | 6e 64 0d 60 60 75 6e 6d |tance) a|nd.``unm|
|00000300| 61 72 73 68 61 6c 6c 69 | 6e 67 27 27 20 66 6f 72 |arshalli|ng'' for|
|00000310| 20 74 68 65 20 72 65 76 | 65 72 73 65 20 70 72 6f | the rev|erse pro|
|00000320| 63 65 73 73 2e 7d 0d 0d | 0d 4e 6f 74 20 61 6c 6c |cess.}..|.Not all|
|00000330| 20 50 79 74 68 6f 6e 20 | 6f 62 6a 65 63 74 20 74 | Python |object t|
|00000340| 79 70 65 73 20 61 72 65 | 20 73 75 70 70 6f 72 74 |ypes are| support|
|00000350| 65 64 3b 20 69 6e 20 67 | 65 6e 65 72 61 6c 2c 20 |ed; in g|eneral, |
|00000360| 6f 6e 6c 79 20 6f 62 6a | 65 63 74 73 0d 77 68 6f |only obj|ects.who|
|00000370| 73 65 20 76 61 6c 75 65 | 20 69 73 20 69 6e 64 65 |se value| is inde|
|00000380| 70 65 6e 64 65 6e 74 20 | 66 72 6f 6d 20 61 20 70 |pendent |from a p|
|00000390| 61 72 74 69 63 75 6c 61 | 72 20 69 6e 76 6f 63 61 |articula|r invoca|
|000003a0| 74 69 6f 6e 20 6f 66 20 | 50 79 74 68 6f 6e 20 63 |tion of |Python c|
|000003b0| 61 6e 0d 62 65 20 77 72 | 69 74 74 65 6e 20 61 6e |an.be wr|itten an|
|000003c0| 64 20 72 65 61 64 20 62 | 79 20 74 68 69 73 20 6d |d read b|y this m|
|000003d0| 6f 64 75 6c 65 2e 20 20 | 54 68 65 20 66 6f 6c 6c |odule. |The foll|
|000003e0| 6f 77 69 6e 67 20 74 79 | 70 65 73 20 61 72 65 20 |owing ty|pes are |
|000003f0| 73 75 70 70 6f 72 74 65 | 64 3a 0d 5c 63 6f 64 65 |supporte|d:.\code|
|00000400| 7b 4e 6f 6e 65 7d 2c 20 | 69 6e 74 65 67 65 72 73 |{None}, |integers|
|00000410| 2c 20 6c 6f 6e 67 20 69 | 6e 74 65 67 65 72 73 2c |, long i|ntegers,|
|00000420| 20 66 6c 6f 61 74 69 6e | 67 20 70 6f 69 6e 74 20 | floatin|g point |
|00000430| 6e 75 6d 62 65 72 73 2c | 0d 73 74 72 69 6e 67 73 |numbers,|.strings|
|00000440| 2c 20 74 75 70 6c 65 73 | 2c 20 6c 69 73 74 73 2c |, tuples|, lists,|
|00000450| 20 64 69 63 74 69 6f 6e | 61 72 69 65 73 2c 20 61 | diction|aries, a|
|00000460| 6e 64 20 63 6f 64 65 20 | 6f 62 6a 65 63 74 73 2c |nd code |objects,|
|00000470| 20 77 68 65 72 65 20 69 | 74 0d 73 68 6f 75 6c 64 | where i|t.should|
|00000480| 20 62 65 20 75 6e 64 65 | 72 73 74 6f 6f 64 20 74 | be unde|rstood t|
|00000490| 68 61 74 20 74 75 70 6c | 65 73 2c 20 6c 69 73 74 |hat tupl|es, list|
|000004a0| 73 20 61 6e 64 20 64 69 | 63 74 69 6f 6e 61 72 69 |s and di|ctionari|
|000004b0| 65 73 20 61 72 65 20 6f | 6e 6c 79 0d 73 75 70 70 |es are o|nly.supp|
|000004c0| 6f 72 74 65 64 20 61 73 | 20 6c 6f 6e 67 20 61 73 |orted as| long as|
|000004d0| 20 74 68 65 20 76 61 6c | 75 65 73 20 63 6f 6e 74 | the val|ues cont|
|000004e0| 61 69 6e 65 64 20 74 68 | 65 72 65 69 6e 20 61 72 |ained th|erein ar|
|000004f0| 65 20 74 68 65 6d 73 65 | 6c 76 65 73 0d 73 75 70 |e themse|lves.sup|
|00000500| 70 6f 72 74 65 64 3b 20 | 61 6e 64 20 72 65 63 75 |ported; |and recu|
|00000510| 72 73 69 76 65 20 6c 69 | 73 74 73 20 61 6e 64 20 |rsive li|sts and |
|00000520| 64 69 63 74 69 6f 6e 61 | 72 69 65 73 20 73 68 6f |dictiona|ries sho|
|00000530| 75 6c 64 20 6e 6f 74 20 | 62 65 20 77 72 69 74 74 |uld not |be writt|
|00000540| 65 6e 0d 28 74 68 65 79 | 20 77 69 6c 6c 20 63 61 |en.(they| will ca|
|00000550| 75 73 65 20 61 6e 20 69 | 6e 66 69 6e 69 74 65 20 |use an i|nfinite |
|00000560| 6c 6f 6f 70 29 2e 0d 0d | 54 68 65 72 65 20 61 72 |loop)...|There ar|
|00000570| 65 20 66 75 6e 63 74 69 | 6f 6e 73 20 74 68 61 74 |e functi|ons that|
|00000580| 20 72 65 61 64 2f 77 72 | 69 74 65 20 66 69 6c 65 | read/wr|ite file|
|00000590| 73 20 61 73 20 77 65 6c | 6c 20 61 73 20 66 75 6e |s as wel|l as fun|
|000005a0| 63 74 69 6f 6e 73 0d 6f | 70 65 72 61 74 69 6e 67 |ctions.o|perating|
|000005b0| 20 6f 6e 20 73 74 72 69 | 6e 67 73 2e 0d 0d 54 68 | on stri|ngs...Th|
|000005c0| 65 20 6d 6f 64 75 6c 65 | 20 64 65 66 69 6e 65 73 |e module| defines|
|000005d0| 20 74 68 65 73 65 20 66 | 75 6e 63 74 69 6f 6e 73 | these f|unctions|
|000005e0| 3a 0d 0d 5c 72 65 6e 65 | 77 63 6f 6d 6d 61 6e 64 |:..\rene|wcommand|
|000005f0| 7b 5c 69 6e 64 65 78 73 | 75 62 69 74 65 6d 7d 7b |{\indexs|ubitem}{|
|00000600| 28 69 6e 20 6d 6f 64 75 | 6c 65 20 6d 61 72 73 68 |(in modu|le marsh|
|00000610| 61 6c 29 7d 0d 5c 62 65 | 67 69 6e 7b 66 75 6e 63 |al)}.\be|gin{func|
|00000620| 64 65 73 63 7d 7b 64 75 | 6d 70 7d 7b 76 61 6c 75 |desc}{du|mp}{valu|
|00000630| 65 5c 2c 20 66 69 6c 65 | 7d 0d 20 20 57 72 69 74 |e\, file|}. Writ|
|00000640| 65 20 74 68 65 20 76 61 | 6c 75 65 20 6f 6e 20 74 |e the va|lue on t|
|00000650| 68 65 20 6f 70 65 6e 20 | 66 69 6c 65 2e 20 20 54 |he open |file. T|
|00000660| 68 65 20 76 61 6c 75 65 | 20 6d 75 73 74 20 62 65 |he value| must be|
|00000670| 20 61 20 73 75 70 70 6f | 72 74 65 64 0d 20 20 74 | a suppo|rted. t|
|00000680| 79 70 65 2e 20 20 54 68 | 65 20 66 69 6c 65 20 6d |ype. Th|e file m|
|00000690| 75 73 74 20 62 65 20 61 | 6e 20 6f 70 65 6e 20 66 |ust be a|n open f|
|000006a0| 69 6c 65 20 6f 62 6a 65 | 63 74 20 73 75 63 68 20 |ile obje|ct such |
|000006b0| 61 73 0d 20 20 5c 63 6f | 64 65 7b 73 79 73 2e 73 |as. \co|de{sys.s|
|000006c0| 74 64 6f 75 74 7d 20 6f | 72 20 72 65 74 75 72 6e |tdout} o|r return|
|000006d0| 65 64 20 62 79 20 5c 63 | 6f 64 65 7b 6f 70 65 6e |ed by \c|ode{open|
|000006e0| 28 29 7d 20 6f 72 0d 20 | 20 5c 63 6f 64 65 7b 70 |()} or. | \code{p|
|000006f0| 6f 73 69 78 2e 70 6f 70 | 65 6e 28 29 7d 2e 0d 20 |osix.pop|en()}.. |
|00000700| 20 0d 20 20 49 66 20 74 | 68 65 20 76 61 6c 75 65 | . If t|he value|
|00000710| 20 68 61 73 20 61 6e 20 | 75 6e 73 75 70 70 6f 72 | has an |unsuppor|
|00000720| 74 65 64 20 74 79 70 65 | 2c 20 67 61 72 62 61 67 |ted type|, garbag|
|00000730| 65 20 69 73 20 77 72 69 | 74 74 65 6e 20 77 68 69 |e is wri|tten whi|
|00000740| 63 68 20 63 61 6e 6e 6f | 74 0d 20 20 62 65 20 72 |ch canno|t. be r|
|00000750| 65 61 64 20 62 61 63 6b | 20 62 79 20 5c 63 6f 64 |ead back| by \cod|
|00000760| 65 7b 6c 6f 61 64 28 29 | 7d 2e 0d 5c 65 6e 64 7b |e{load()|}..\end{|
|00000770| 66 75 6e 63 64 65 73 63 | 7d 0d 0d 5c 62 65 67 69 |funcdesc|}..\begi|
|00000780| 6e 7b 66 75 6e 63 64 65 | 73 63 7d 7b 6c 6f 61 64 |n{funcde|sc}{load|
|00000790| 7d 7b 66 69 6c 65 7d 0d | 20 20 52 65 61 64 20 6f |}{file}.| Read o|
|000007a0| 6e 65 20 76 61 6c 75 65 | 20 66 72 6f 6d 20 74 68 |ne value| from th|
|000007b0| 65 20 6f 70 65 6e 20 66 | 69 6c 65 20 61 6e 64 20 |e open f|ile and |
|000007c0| 72 65 74 75 72 6e 20 69 | 74 2e 20 20 49 66 20 6e |return i|t. If n|
|000007d0| 6f 20 76 61 6c 69 64 20 | 76 61 6c 75 65 0d 20 20 |o valid |value. |
|000007e0| 69 73 20 72 65 61 64 2c | 20 72 61 69 73 65 20 5c |is read,| raise \|
|000007f0| 63 6f 64 65 7b 45 4f 46 | 45 72 72 6f 72 7d 2c 20 |code{EOF|Error}, |
|00000800| 5c 63 6f 64 65 7b 56 61 | 6c 75 65 45 72 72 6f 72 |\code{Va|lueError|
|00000810| 7d 20 6f 72 0d 20 20 5c | 63 6f 64 65 7b 54 79 70 |} or. \|code{Typ|
|00000820| 65 45 72 72 6f 72 7d 2e | 20 20 54 68 65 20 66 69 |eError}.| The fi|
|00000830| 6c 65 20 6d 75 73 74 20 | 62 65 20 61 6e 20 6f 70 |le must |be an op|
|00000840| 65 6e 20 66 69 6c 65 20 | 6f 62 6a 65 63 74 2e 0d |en file |object..|
|00000850| 5c 65 6e 64 7b 66 75 6e | 63 64 65 73 63 7d 0d 0d |\end{fun|cdesc}..|
|00000860| 5c 62 65 67 69 6e 7b 66 | 75 6e 63 64 65 73 63 7d |\begin{f|uncdesc}|
|00000870| 7b 64 75 6d 70 73 7d 7b | 76 61 6c 75 65 7d 0d 20 |{dumps}{|value}. |
|00000880| 20 52 65 74 75 72 6e 20 | 74 68 65 20 73 74 72 69 | Return |the stri|
|00000890| 6e 67 20 74 68 61 74 20 | 77 6f 75 6c 64 20 62 65 |ng that |would be|
|000008a0| 20 77 72 69 74 74 65 6e | 20 74 6f 20 61 20 66 69 | written| to a fi|
|000008b0| 6c 65 20 62 79 0d 20 20 | 5c 63 6f 64 65 7b 64 75 |le by. |\code{du|
|000008c0| 6d 70 28 76 61 6c 75 65 | 2c 20 66 69 6c 65 29 7d |mp(value|, file)}|
|000008d0| 2e 20 20 54 68 65 20 76 | 61 6c 75 65 20 6d 75 73 |. The v|alue mus|
|000008e0| 74 20 62 65 20 61 20 73 | 75 70 70 6f 72 74 65 64 |t be a s|upported|
|000008f0| 20 74 79 70 65 2e 0d 5c | 65 6e 64 7b 66 75 6e 63 | type..\|end{func|
|00000900| 64 65 73 63 7d 0d 0d 5c | 62 65 67 69 6e 7b 66 75 |desc}..\|begin{fu|
|00000910| 6e 63 64 65 73 63 7d 7b | 6c 6f 61 64 73 7d 7b 73 |ncdesc}{|loads}{s|
|00000920| 74 72 69 6e 67 7d 0d 20 | 20 43 6f 6e 76 65 72 74 |tring}. | Convert|
|00000930| 20 74 68 65 20 73 74 72 | 69 6e 67 20 74 6f 20 61 | the str|ing to a|
|00000940| 20 76 61 6c 75 65 2e 20 | 20 49 66 20 6e 6f 20 76 | value. | If no v|
|00000950| 61 6c 69 64 20 76 61 6c | 75 65 20 69 73 20 66 6f |alid val|ue is fo|
|00000960| 75 6e 64 2c 20 72 61 69 | 73 65 0d 20 20 5c 63 6f |und, rai|se. \co|
|00000970| 64 65 7b 45 4f 46 45 72 | 72 6f 72 7d 2c 20 5c 63 |de{EOFEr|ror}, \c|
|00000980| 6f 64 65 7b 56 61 6c 75 | 65 45 72 72 6f 72 7d 20 |ode{Valu|eError} |
|00000990| 6f 72 20 5c 63 6f 64 65 | 7b 54 79 70 65 45 72 72 |or \code|{TypeErr|
|000009a0| 6f 72 7d 2e 20 20 45 78 | 74 72 61 0d 20 20 63 68 |or}. Ex|tra. ch|
|000009b0| 61 72 61 63 74 65 72 73 | 20 69 6e 20 74 68 65 20 |aracters| in the |
|000009c0| 73 74 72 69 6e 67 20 61 | 72 65 20 69 67 6e 6f 72 |string a|re ignor|
|000009d0| 65 64 2e 0d 5c 65 6e 64 | 7b 66 75 6e 63 64 65 73 |ed..\end|{funcdes|
|000009e0| 63 7d 0d | |c}. | |
+--------+-------------------------+-------------------------+--------+--------+