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%
| detectItEasy
| Format: plain text[LF]
| default (weak)
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 53 74 61 6e 64 61 72 |\section|{Standar|
|00000010| 64 20 4d 6f 64 75 6c 65 | 20 5c 73 65 63 74 63 6f |d Module| \sectco|
|00000020| 64 65 7b 73 68 65 6c 76 | 65 7d 7d 0a 5c 73 74 6d |de{shelv|e}}.\stm|
|00000030| 6f 64 69 6e 64 65 78 7b | 73 68 65 6c 76 65 7d 0a |odindex{|shelve}.|
|00000040| 5c 73 74 6d 6f 64 69 6e | 64 65 78 7b 70 69 63 6b |\stmodin|dex{pick|
|00000050| 6c 65 7d 0a 5c 62 69 6d | 6f 64 69 6e 64 65 78 7b |le}.\bim|odindex{|
|00000060| 64 62 6d 7d 0a 5c 62 69 | 6d 6f 64 69 6e 64 65 78 |dbm}.\bi|modindex|
|00000070| 7b 67 64 62 6d 7d 0a 0a | 41 20 60 60 73 68 65 6c |{gdbm}..|A ``shel|
|00000080| 66 27 27 20 69 73 20 61 | 20 70 65 72 73 69 73 74 |f'' is a| persist|
|00000090| 65 6e 74 2c 20 64 69 63 | 74 69 6f 6e 61 72 79 2d |ent, dic|tionary-|
|000000a0| 6c 69 6b 65 20 6f 62 6a | 65 63 74 2e 20 20 54 68 |like obj|ect. Th|
|000000b0| 65 20 64 69 66 66 65 72 | 65 6e 63 65 0a 77 69 74 |e differ|ence.wit|
|000000c0| 68 20 60 60 64 62 6d 27 | 27 20 64 61 74 61 62 61 |h ``dbm'|' databa|
|000000d0| 73 65 73 20 69 73 20 74 | 68 61 74 20 74 68 65 20 |ses is t|hat the |
|000000e0| 76 61 6c 75 65 73 20 28 | 6e 6f 74 20 74 68 65 20 |values (|not the |
|000000f0| 6b 65 79 73 21 29 20 69 | 6e 20 61 20 73 68 65 6c |keys!) i|n a shel|
|00000100| 66 0a 63 61 6e 20 62 65 | 20 65 73 73 65 6e 74 69 |f.can be| essenti|
|00000110| 61 6c 6c 79 20 61 72 62 | 69 74 72 61 72 79 20 50 |ally arb|itrary P|
|00000120| 79 74 68 6f 6e 20 6f 62 | 6a 65 63 74 73 20 2d 2d |ython ob|jects --|
|00000130| 2d 20 61 6e 79 74 68 69 | 6e 67 20 74 68 61 74 20 |- anythi|ng that |
|00000140| 74 68 65 0a 5c 63 6f 64 | 65 7b 70 69 63 6b 6c 65 |the.\cod|e{pickle|
|00000150| 7d 20 6d 6f 64 75 6c 65 | 20 63 61 6e 20 68 61 6e |} module| can han|
|00000160| 64 6c 65 2e 20 20 54 68 | 69 73 20 69 6e 63 6c 75 |dle. Th|is inclu|
|00000170| 64 65 73 20 6d 6f 73 74 | 20 63 6c 61 73 73 20 69 |des most| class i|
|00000180| 6e 73 74 61 6e 63 65 73 | 2c 0a 72 65 63 75 72 73 |nstances|,.recurs|
|00000190| 69 76 65 20 64 61 74 61 | 20 74 79 70 65 73 2c 20 |ive data| types, |
|000001a0| 61 6e 64 20 6f 62 6a 65 | 63 74 73 20 63 6f 6e 74 |and obje|cts cont|
|000001b0| 61 69 6e 69 6e 67 20 6c | 6f 74 73 20 6f 66 20 73 |aining l|ots of s|
|000001c0| 68 61 72 65 64 0a 73 75 | 62 2d 6f 62 6a 65 63 74 |hared.su|b-object|
|000001d0| 73 2e 20 20 54 68 65 20 | 6b 65 79 73 20 61 72 65 |s. The |keys are|
|000001e0| 20 6f 72 64 69 6e 61 72 | 79 20 73 74 72 69 6e 67 | ordinar|y string|
|000001f0| 73 2e 0a 0a 54 6f 20 73 | 75 6d 6d 61 72 69 7a 65 |s...To s|ummarize|
|00000200| 20 74 68 65 20 69 6e 74 | 65 72 66 61 63 65 20 28 | the int|erface (|
|00000210| 5c 63 6f 64 65 7b 6b 65 | 79 7d 20 69 73 20 61 20 |\code{ke|y} is a |
|00000220| 73 74 72 69 6e 67 2c 20 | 5c 63 6f 64 65 7b 64 61 |string, |\code{da|
|00000230| 74 61 7d 20 69 73 20 61 | 6e 0a 61 72 62 69 74 72 |ta} is a|n.arbitr|
|00000240| 61 72 79 20 6f 62 6a 65 | 63 74 29 3a 0a 0a 5c 62 |ary obje|ct):..\b|
|00000250| 65 67 69 6e 7b 76 65 72 | 62 61 74 69 6d 7d 0a 69 |egin{ver|batim}.i|
|00000260| 6d 70 6f 72 74 20 73 68 | 65 6c 76 65 0a 0a 64 20 |mport sh|elve..d |
|00000270| 3d 20 73 68 65 6c 76 65 | 2e 6f 70 65 6e 28 66 69 |= shelve|.open(fi|
|00000280| 6c 65 6e 61 6d 65 29 20 | 23 20 6f 70 65 6e 2c 20 |lename) |# open, |
|00000290| 77 69 74 68 20 28 67 29 | 64 62 6d 20 66 69 6c 65 |with (g)|dbm file|
|000002a0| 6e 61 6d 65 20 2d 2d 20 | 6e 6f 20 73 75 66 66 69 |name -- |no suffi|
|000002b0| 78 0a 0a 64 5b 6b 65 79 | 5d 20 3d 20 64 61 74 61 |x..d[key|] = data|
|000002c0| 20 20 20 23 20 73 74 6f | 72 65 20 64 61 74 61 20 | # sto|re data |
|000002d0| 61 74 20 6b 65 79 20 28 | 6f 76 65 72 77 72 69 74 |at key (|overwrit|
|000002e0| 65 73 20 6f 6c 64 20 64 | 61 74 61 20 69 66 0a 20 |es old d|ata if. |
|000002f0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 23 | | #|
|00000300| 20 75 73 69 6e 67 20 61 | 6e 20 65 78 69 73 74 69 | using a|n existi|
|00000310| 6e 67 20 6b 65 79 29 0a | 64 61 74 61 20 3d 20 64 |ng key).|data = d|
|00000320| 5b 6b 65 79 5d 20 20 20 | 23 20 72 65 74 72 69 65 |[key] |# retrie|
|00000330| 76 65 20 64 61 74 61 20 | 61 74 20 6b 65 79 20 28 |ve data |at key (|
|00000340| 72 61 69 73 65 20 4b 65 | 79 45 72 72 6f 72 20 69 |raise Ke|yError i|
|00000350| 66 20 6e 6f 0a 20 20 20 | 20 20 20 20 20 20 20 20 |f no. | |
|00000360| 20 20 20 20 20 23 20 73 | 75 63 68 20 6b 65 79 29 | # s|uch key)|
|00000370| 0a 64 65 6c 20 64 5b 6b | 65 79 5d 20 20 20 20 20 |.del d[k|ey] |
|00000380| 20 23 20 64 65 6c 65 74 | 65 20 64 61 74 61 20 73 | # delet|e data s|
|00000390| 74 6f 72 65 64 20 61 74 | 20 6b 65 79 20 28 72 61 |tored at| key (ra|
|000003a0| 69 73 65 73 20 4b 65 79 | 45 72 72 6f 72 0a 20 20 |ises Key|Error. |
|000003b0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 23 20 | | # |
|000003c0| 69 66 20 6e 6f 20 73 75 | 63 68 20 6b 65 79 29 0a |if no su|ch key).|
|000003d0| 66 6c 61 67 20 3d 20 64 | 2e 68 61 73 5f 6b 65 79 |flag = d|.has_key|
|000003e0| 28 6b 65 79 29 20 20 20 | 23 20 74 72 75 65 20 69 |(key) |# true i|
|000003f0| 66 20 74 68 65 20 6b 65 | 79 20 65 78 69 73 74 73 |f the ke|y exists|
|00000400| 0a 6c 69 73 74 20 3d 20 | 64 2e 6b 65 79 73 28 29 |.list = |d.keys()|
|00000410| 20 23 20 61 20 6c 69 73 | 74 20 6f 66 20 61 6c 6c | # a lis|t of all|
|00000420| 20 65 78 69 73 74 69 6e | 67 20 6b 65 79 73 20 28 | existin|g keys (|
|00000430| 73 6c 6f 77 21 29 0a 0a | 64 2e 63 6c 6f 73 65 28 |slow!)..|d.close(|
|00000440| 29 20 20 20 20 20 20 20 | 23 20 63 6c 6f 73 65 20 |) |# close |
|00000450| 69 74 0a 5c 65 6e 64 7b | 76 65 72 62 61 74 69 6d |it.\end{|verbatim|
|00000460| 7d 0a 0a 52 65 73 74 72 | 69 63 74 69 6f 6e 73 3a |}..Restr|ictions:|
|00000470| 0a 0a 5c 62 65 67 69 6e | 7b 69 74 65 6d 69 7a 65 |..\begin|{itemize|
|00000480| 7d 0a 0a 5c 69 74 65 6d | 0a 54 68 65 20 63 68 6f |}..\item|.The cho|
|00000490| 69 63 65 20 6f 66 20 77 | 68 69 63 68 20 64 61 74 |ice of w|hich dat|
|000004a0| 61 62 61 73 65 20 70 61 | 63 6b 61 67 65 20 77 69 |abase pa|ckage wi|
|000004b0| 6c 6c 20 62 65 20 75 73 | 65 64 20 28 65 2e 67 2e |ll be us|ed (e.g.|
|000004c0| 20 64 62 6d 20 6f 72 20 | 67 64 62 6d 29 0a 64 65 | dbm or |gdbm).de|
|000004d0| 70 65 6e 64 73 20 6f 6e | 20 77 68 69 63 68 20 69 |pends on| which i|
|000004e0| 6e 74 65 72 66 61 63 65 | 20 69 73 20 61 76 61 69 |nterface| is avai|
|000004f0| 6c 61 62 6c 65 2e 20 20 | 54 68 65 72 65 66 6f 72 |lable. |Therefor|
|00000500| 65 20 69 74 20 69 73 6e | 27 74 20 73 61 66 65 20 |e it isn|'t safe |
|00000510| 74 6f 0a 6f 70 65 6e 20 | 74 68 65 20 64 61 74 61 |to.open |the data|
|00000520| 62 61 73 65 20 64 69 72 | 65 63 74 6c 79 20 75 73 |base dir|ectly us|
|00000530| 69 6e 67 20 64 62 6d 2e | 20 20 54 68 65 20 64 61 |ing dbm.| The da|
|00000540| 74 61 62 61 73 65 20 69 | 73 20 61 6c 73 6f 0a 28 |tabase i|s also.(|
|00000550| 75 6e 66 6f 72 74 75 6e | 61 74 65 6c 79 29 20 73 |unfortun|ately) s|
|00000560| 75 62 6a 65 63 74 20 74 | 6f 20 74 68 65 20 6c 69 |ubject t|o the li|
|00000570| 6d 69 74 61 74 69 6f 6e | 73 20 6f 66 20 64 62 6d |mitation|s of dbm|
|00000580| 2c 20 69 66 20 69 74 20 | 69 73 20 75 73 65 64 20 |, if it |is used |
|00000590| 2d 2d 2d 0a 74 68 69 73 | 20 6d 65 61 6e 73 20 74 |---.this| means t|
|000005a0| 68 61 74 20 28 74 68 65 | 20 70 69 63 6b 6c 65 64 |hat (the| pickled|
|000005b0| 20 72 65 70 72 65 73 65 | 6e 74 61 74 69 6f 6e 20 | represe|ntation |
|000005c0| 6f 66 29 20 74 68 65 20 | 6f 62 6a 65 63 74 73 20 |of) the |objects |
|000005d0| 73 74 6f 72 65 64 20 69 | 6e 0a 74 68 65 20 64 61 |stored i|n.the da|
|000005e0| 74 61 62 61 73 65 20 73 | 68 6f 75 6c 64 20 62 65 |tabase s|hould be|
|000005f0| 20 66 61 69 72 6c 79 20 | 73 6d 61 6c 6c 2c 20 61 | fairly |small, a|
|00000600| 6e 64 20 69 6e 20 72 61 | 72 65 20 63 61 73 65 73 |nd in ra|re cases|
|00000610| 20 6b 65 79 20 63 6f 6c | 6c 69 73 69 6f 6e 73 0a | key col|lisions.|
|00000620| 6d 61 79 20 63 61 75 73 | 65 20 74 68 65 20 64 61 |may caus|e the da|
|00000630| 74 61 62 61 73 65 20 74 | 6f 20 72 65 66 75 73 65 |tabase t|o refuse|
|00000640| 20 75 70 64 61 74 65 73 | 2e 0a 0a 5c 69 74 65 6d | updates|...\item|
|00000650| 0a 44 65 70 65 6e 64 65 | 6e 74 20 6f 6e 20 74 68 |.Depende|nt on th|
|00000660| 65 20 69 6d 70 6c 65 6d | 65 6e 74 61 74 69 6f 6e |e implem|entation|
|00000670| 2c 20 63 6c 6f 73 69 6e | 67 20 61 20 70 65 72 73 |, closin|g a pers|
|00000680| 69 73 74 65 6e 74 20 64 | 69 63 74 69 6f 6e 61 72 |istent d|ictionar|
|00000690| 79 20 6d 61 79 0a 6f 72 | 20 6d 61 79 20 6e 6f 74 |y may.or| may not|
|000006a0| 20 62 65 20 6e 65 63 65 | 73 73 61 72 79 20 74 6f | be nece|ssary to|
|000006b0| 20 66 6c 75 73 68 20 63 | 68 61 6e 67 65 73 20 74 | flush c|hanges t|
|000006c0| 6f 20 64 69 73 6b 2e 0a | 0a 5c 69 74 65 6d 0a 54 |o disk..|.\item.T|
|000006d0| 68 65 20 5c 63 6f 64 65 | 7b 73 68 65 6c 76 65 7d |he \code|{shelve}|
|000006e0| 20 6d 6f 64 75 6c 65 20 | 64 6f 65 73 20 6e 6f 74 | module |does not|
|000006f0| 20 73 75 70 70 6f 72 74 | 20 7b 5c 65 6d 20 63 6f | support| {\em co|
|00000700| 6e 63 75 72 72 65 6e 74 | 7d 20 72 65 61 64 2f 77 |ncurrent|} read/w|
|00000710| 72 69 74 65 0a 61 63 63 | 65 73 73 20 74 6f 20 73 |rite.acc|ess to s|
|00000720| 68 65 6c 76 65 64 20 6f | 62 6a 65 63 74 73 2e 20 |helved o|bjects. |
|00000730| 20 28 4d 75 6c 74 69 70 | 6c 65 20 73 69 6d 75 6c | (Multip|le simul|
|00000740| 74 61 6e 65 6f 75 73 20 | 72 65 61 64 20 61 63 63 |taneous |read acc|
|00000750| 65 73 73 65 73 20 61 72 | 65 0a 73 61 66 65 2e 29 |esses ar|e.safe.)|
|00000760| 20 20 57 68 65 6e 20 61 | 20 70 72 6f 67 72 61 6d | When a| program|
|00000770| 20 68 61 73 20 61 20 73 | 68 65 6c 66 20 6f 70 65 | has a s|helf ope|
|00000780| 6e 20 66 6f 72 20 77 72 | 69 74 69 6e 67 2c 20 6e |n for wr|iting, n|
|00000790| 6f 20 6f 74 68 65 72 20 | 70 72 6f 67 72 61 6d 0a |o other |program.|
|000007a0| 73 68 6f 75 6c 64 20 68 | 61 76 65 20 69 74 20 6f |should h|ave it o|
|000007b0| 70 65 6e 20 66 6f 72 20 | 72 65 61 64 69 6e 67 20 |pen for |reading |
|000007c0| 6f 72 20 77 72 69 74 69 | 6e 67 2e 20 20 5c 55 4e |or writi|ng. \UN|
|000007d0| 49 58 7b 7d 20 66 69 6c | 65 20 6c 6f 63 6b 69 6e |IX{} fil|e lockin|
|000007e0| 67 20 63 61 6e 0a 62 65 | 20 75 73 65 64 20 74 6f |g can.be| used to|
|000007f0| 20 73 6f 6c 76 65 20 74 | 68 69 73 2c 20 62 75 74 | solve t|his, but|
|00000800| 20 74 68 69 73 20 64 69 | 66 66 65 72 73 20 61 63 | this di|ffers ac|
|00000810| 72 6f 73 73 20 5c 55 4e | 49 58 7b 7d 20 76 65 72 |ross \UN|IX{} ver|
|00000820| 73 69 6f 6e 73 20 61 6e | 64 0a 72 65 71 75 69 72 |sions an|d.requir|
|00000830| 65 73 20 6b 6e 6f 77 6c | 65 64 67 65 20 61 62 6f |es knowl|edge abo|
|00000840| 75 74 20 74 68 65 20 64 | 61 74 61 62 61 73 65 20 |ut the d|atabase |
|00000850| 69 6d 70 6c 65 6d 65 6e | 74 61 74 69 6f 6e 20 75 |implemen|tation u|
|00000860| 73 65 64 2e 0a 0a 5c 65 | 6e 64 7b 69 74 65 6d 69 |sed...\e|nd{itemi|
|00000870| 7a 65 7d 0a | |ze}. | |
+--------+-------------------------+-------------------------+--------+--------+