home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / python / pytex / pytexdoc / lib1 / excs / tex
LaTeX Document  |  1996-11-08  |  7.2 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 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 45 78 63 65 70 74 | 69 6f 6e 73 7d 0a 0a 45 |n Except|ions}..E|
|00000020| 78 63 65 70 74 69 6f 6e | 73 20 61 72 65 20 73 74 |xception|s are st|
|00000030| 72 69 6e 67 20 6f 62 6a | 65 63 74 73 2e 20 20 54 |ring obj|ects. T|
|00000040| 77 6f 20 64 69 73 74 69 | 6e 63 74 20 73 74 72 69 |wo disti|nct stri|
|00000050| 6e 67 20 6f 62 6a 65 63 | 74 73 20 77 69 74 68 20 |ng objec|ts with |
|00000060| 74 68 65 0a 73 61 6d 65 | 20 76 61 6c 75 65 20 61 |the.same| value a|
|00000070| 72 65 20 64 69 66 66 65 | 72 65 6e 74 20 65 78 63 |re diffe|rent exc|
|00000080| 65 70 74 69 6f 6e 73 2e | 20 20 54 68 69 73 20 69 |eptions.| This i|
|00000090| 73 20 64 6f 6e 65 20 74 | 6f 20 66 6f 72 63 65 20 |s done t|o force |
|000000a0| 70 72 6f 67 72 61 6d 6d | 65 72 73 0a 74 6f 20 75 |programm|ers.to u|
|000000b0| 73 65 20 65 78 63 65 70 | 74 69 6f 6e 20 6e 61 6d |se excep|tion nam|
|000000c0| 65 73 20 72 61 74 68 65 | 72 20 74 68 61 6e 20 74 |es rathe|r than t|
|000000d0| 68 65 69 72 20 73 74 72 | 69 6e 67 20 76 61 6c 75 |heir str|ing valu|
|000000e0| 65 20 77 68 65 6e 20 73 | 70 65 63 69 66 79 69 6e |e when s|pecifyin|
|000000f0| 67 0a 65 78 63 65 70 74 | 69 6f 6e 20 68 61 6e 64 |g.except|ion hand|
|00000100| 6c 65 72 73 2e 20 20 54 | 68 65 20 73 74 72 69 6e |lers. T|he strin|
|00000110| 67 20 76 61 6c 75 65 20 | 6f 66 20 61 6c 6c 20 62 |g value |of all b|
|00000120| 75 69 6c 74 2d 69 6e 20 | 65 78 63 65 70 74 69 6f |uilt-in |exceptio|
|00000130| 6e 73 20 69 73 0a 74 68 | 65 69 72 20 6e 61 6d 65 |ns is.th|eir name|
|00000140| 2c 20 62 75 74 20 74 68 | 69 73 20 69 73 20 6e 6f |, but th|is is no|
|00000150| 74 20 61 20 72 65 71 75 | 69 72 65 6d 65 6e 74 20 |t a requ|irement |
|00000160| 66 6f 72 20 75 73 65 72 | 2d 64 65 66 69 6e 65 64 |for user|-defined|
|00000170| 20 65 78 63 65 70 74 69 | 6f 6e 73 0a 6f 72 20 65 | excepti|ons.or e|
|00000180| 78 63 65 70 74 69 6f 6e | 73 20 64 65 66 69 6e 65 |xception|s define|
|00000190| 64 20 62 79 20 6c 69 62 | 72 61 72 79 20 6d 6f 64 |d by lib|rary mod|
|000001a0| 75 6c 65 73 2e 0a 0a 54 | 68 65 20 66 6f 6c 6c 6f |ules...T|he follo|
|000001b0| 77 69 6e 67 20 65 78 63 | 65 70 74 69 6f 6e 73 20 |wing exc|eptions |
|000001c0| 63 61 6e 20 62 65 20 67 | 65 6e 65 72 61 74 65 64 |can be g|enerated|
|000001d0| 20 62 79 20 74 68 65 20 | 69 6e 74 65 72 70 72 65 | by the |interpre|
|000001e0| 74 65 72 20 6f 72 0a 62 | 75 69 6c 74 2d 69 6e 20 |ter or.b|uilt-in |
|000001f0| 66 75 6e 63 74 69 6f 6e | 73 2e 20 20 45 78 63 65 |function|s. Exce|
|00000200| 70 74 20 77 68 65 72 65 | 20 6d 65 6e 74 69 6f 6e |pt where| mention|
|00000210| 65 64 2c 20 74 68 65 79 | 20 68 61 76 65 20 61 6e |ed, they| have an|
|00000220| 20 60 61 73 73 6f 63 69 | 61 74 65 64 0a 76 61 6c | `associ|ated.val|
|00000230| 75 65 27 20 69 6e 64 69 | 63 61 74 69 6e 67 20 74 |ue' indi|cating t|
|00000240| 68 65 20 64 65 74 61 69 | 6c 65 64 20 63 61 75 73 |he detai|led caus|
|00000250| 65 20 6f 66 20 74 68 65 | 20 65 72 72 6f 72 2e 20 |e of the| error. |
|00000260| 20 54 68 69 73 20 6d 61 | 79 20 62 65 20 61 0a 73 | This ma|y be a.s|
|00000270| 74 72 69 6e 67 20 6f 72 | 20 61 20 74 75 70 6c 65 |tring or| a tuple|
|00000280| 20 63 6f 6e 74 61 69 6e | 69 6e 67 20 73 65 76 65 | contain|ing seve|
|00000290| 72 61 6c 20 69 74 65 6d | 73 20 6f 66 20 69 6e 66 |ral item|s of inf|
|000002a0| 6f 72 6d 61 74 69 6f 6e | 20 28 65 2e 67 2e 2c 20 |ormation| (e.g., |
|000002b0| 61 6e 0a 65 72 72 6f 72 | 20 63 6f 64 65 20 61 6e |an.error| code an|
|000002c0| 64 20 61 20 73 74 72 69 | 6e 67 20 65 78 70 6c 61 |d a stri|ng expla|
|000002d0| 69 6e 69 6e 67 20 74 68 | 65 20 63 6f 64 65 29 2e |ining th|e code).|
|000002e0| 0a 0a 55 73 65 72 20 63 | 6f 64 65 20 63 61 6e 20 |..User c|ode can |
|000002f0| 72 61 69 73 65 20 62 75 | 69 6c 74 2d 69 6e 20 65 |raise bu|ilt-in e|
|00000300| 78 63 65 70 74 69 6f 6e | 73 2e 20 20 54 68 69 73 |xception|s. This|
|00000310| 20 63 61 6e 20 62 65 20 | 75 73 65 64 20 74 6f 20 | can be |used to |
|00000320| 74 65 73 74 20 61 6e 0a | 65 78 63 65 70 74 69 6f |test an.|exceptio|
|00000330| 6e 20 68 61 6e 64 6c 65 | 72 20 6f 72 20 74 6f 20 |n handle|r or to |
|00000340| 72 65 70 6f 72 74 20 61 | 6e 20 65 72 72 6f 72 20 |report a|n error |
|00000350| 63 6f 6e 64 69 74 69 6f | 6e 20 60 6a 75 73 74 20 |conditio|n `just |
|00000360| 6c 69 6b 65 27 20 74 68 | 65 0a 73 69 74 75 61 74 |like' th|e.situat|
|00000370| 69 6f 6e 20 69 6e 20 77 | 68 69 63 68 20 74 68 65 |ion in w|hich the|
|00000380| 20 69 6e 74 65 72 70 72 | 65 74 65 72 20 72 61 69 | interpr|eter rai|
|00000390| 73 65 73 20 74 68 65 20 | 73 61 6d 65 20 65 78 63 |ses the |same exc|
|000003a0| 65 70 74 69 6f 6e 3b 20 | 62 75 74 0a 62 65 77 61 |eption; |but.bewa|
|000003b0| 72 65 20 74 68 61 74 20 | 74 68 65 72 65 20 69 73 |re that |there is|
|000003c0| 20 6e 6f 74 68 69 6e 67 | 20 74 6f 20 70 72 65 76 | nothing| to prev|
|000003d0| 65 6e 74 20 75 73 65 72 | 20 63 6f 64 65 20 66 72 |ent user| code fr|
|000003e0| 6f 6d 20 72 61 69 73 69 | 6e 67 20 61 6e 0a 69 6e |om raisi|ng an.in|
|000003f0| 61 70 70 72 6f 70 72 69 | 61 74 65 20 65 72 72 6f |appropri|ate erro|
|00000400| 72 2e 0a 0a 5c 72 65 6e | 65 77 63 6f 6d 6d 61 6e |r...\ren|ewcomman|
|00000410| 64 7b 5c 69 6e 64 65 78 | 73 75 62 69 74 65 6d 7d |d{\index|subitem}|
|00000420| 7b 28 62 75 69 6c 74 2d | 69 6e 20 65 78 63 65 70 |{(built-|in excep|
|00000430| 74 69 6f 6e 29 7d 0a 0a | 5c 62 65 67 69 6e 7b 65 |tion)}..|\begin{e|
|00000440| 78 63 64 65 73 63 7d 7b | 41 74 74 72 69 62 75 74 |xcdesc}{|Attribut|
|00000450| 65 45 72 72 6f 72 7d 0a | 25 20 78 72 65 66 20 74 |eError}.|% xref t|
|00000460| 6f 20 61 74 74 72 69 62 | 75 74 65 20 72 65 66 65 |o attrib|ute refe|
|00000470| 72 65 6e 63 65 3f 0a 20 | 20 52 61 69 73 65 64 20 |rence?. | Raised |
|00000480| 77 68 65 6e 20 61 6e 20 | 61 74 74 72 69 62 75 74 |when an |attribut|
|00000490| 65 20 72 65 66 65 72 65 | 6e 63 65 20 6f 72 20 61 |e refere|nce or a|
|000004a0| 73 73 69 67 6e 6d 65 6e | 74 20 66 61 69 6c 73 2e |ssignmen|t fails.|
|000004b0| 20 20 28 57 68 65 6e 20 | 61 6e 0a 20 20 6f 62 6a | (When |an. obj|
|000004c0| 65 63 74 20 64 6f 65 73 | 20 6e 6f 74 20 73 75 70 |ect does| not sup|
|000004d0| 70 6f 72 74 20 61 74 74 | 72 69 62 75 74 65 20 72 |port att|ribute r|
|000004e0| 65 66 65 72 65 6e 63 65 | 73 20 6f 72 20 61 74 74 |eference|s or att|
|000004f0| 72 69 62 75 74 65 20 61 | 73 73 69 67 6e 6d 65 6e |ribute a|ssignmen|
|00000500| 74 73 0a 20 20 61 74 20 | 61 6c 6c 2c 20 5c 63 6f |ts. at |all, \co|
|00000510| 64 65 7b 54 79 70 65 45 | 72 72 6f 72 7d 20 69 73 |de{TypeE|rror} is|
|00000520| 20 72 61 69 73 65 64 2e | 29 0a 5c 65 6e 64 7b 65 | raised.|).\end{e|
|00000530| 78 63 64 65 73 63 7d 0a | 0a 5c 62 65 67 69 6e 7b |xcdesc}.|.\begin{|
|00000540| 65 78 63 64 65 73 63 7d | 7b 45 4f 46 45 72 72 6f |excdesc}|{EOFErro|
|00000550| 72 7d 0a 25 20 58 58 58 | 4a 48 20 78 72 65 66 73 |r}.% XXX|JH xrefs|
|00000560| 20 68 65 72 65 0a 20 20 | 52 61 69 73 65 64 20 77 | here. |Raised w|
|00000570| 68 65 6e 20 6f 6e 65 20 | 6f 66 20 74 68 65 20 62 |hen one |of the b|
|00000580| 75 69 6c 74 2d 69 6e 20 | 66 75 6e 63 74 69 6f 6e |uilt-in |function|
|00000590| 73 20 28 5c 63 6f 64 65 | 7b 69 6e 70 75 74 28 29 |s (\code|{input()|
|000005a0| 7d 20 6f 72 0a 20 20 5c | 63 6f 64 65 7b 72 61 77 |} or. \|code{raw|
|000005b0| 5f 69 6e 70 75 74 28 29 | 7d 29 20 68 69 74 73 20 |_input()|}) hits |
|000005c0| 61 6e 20 65 6e 64 2d 6f | 66 2d 66 69 6c 65 20 63 |an end-o|f-file c|
|000005d0| 6f 6e 64 69 74 69 6f 6e | 20 28 5c 45 4f 46 7b 7d |ondition| (\EOF{}|
|000005e0| 29 20 77 69 74 68 6f 75 | 74 0a 20 20 72 65 61 64 |) withou|t. read|
|000005f0| 69 6e 67 20 61 6e 79 20 | 64 61 74 61 2e 0a 25 20 |ing any |data..% |
|00000600| 58 58 58 4a 48 20 78 72 | 65 66 73 20 68 65 72 65 |XXXJH xr|efs here|
|00000610| 0a 20 20 28 4e 2e 42 2e | 3a 20 74 68 65 20 5c 63 |. (N.B.|: the \c|
|00000620| 6f 64 65 7b 72 65 61 64 | 28 29 7d 20 61 6e 64 20 |ode{read|()} and |
|00000630| 5c 63 6f 64 65 7b 72 65 | 61 64 6c 69 6e 65 28 29 |\code{re|adline()|
|00000640| 7d 20 6d 65 74 68 6f 64 | 73 20 6f 66 20 66 69 6c |} method|s of fil|
|00000650| 65 0a 20 20 6f 62 6a 65 | 63 74 73 20 72 65 74 75 |e. obje|cts retu|
|00000660| 72 6e 20 61 6e 20 65 6d | 70 74 79 20 73 74 72 69 |rn an em|pty stri|
|00000670| 6e 67 20 77 68 65 6e 20 | 74 68 65 79 20 68 69 74 |ng when |they hit|
|00000680| 20 5c 45 4f 46 7b 7d 2e | 29 20 20 4e 6f 20 61 73 | \EOF{}.|) No as|
|00000690| 73 6f 63 69 61 74 65 64 | 20 76 61 6c 75 65 2e 0a |sociated| value..|
|000006a0| 5c 65 6e 64 7b 65 78 63 | 64 65 73 63 7d 0a 0a 5c |\end{exc|desc}..\|
|000006b0| 62 65 67 69 6e 7b 65 78 | 63 64 65 73 63 7d 7b 49 |begin{ex|cdesc}{I|
|000006c0| 4f 45 72 72 6f 72 7d 0a | 25 20 58 58 58 4a 48 20 |OError}.|% XXXJH |
|000006d0| 78 72 65 66 73 20 68 65 | 72 65 0a 20 20 52 61 69 |xrefs he|re. Rai|
|000006e0| 73 65 64 20 77 68 65 6e | 20 61 6e 20 49 2f 4f 20 |sed when| an I/O |
|000006f0| 6f 70 65 72 61 74 69 6f | 6e 20 28 73 75 63 68 20 |operatio|n (such |
|00000700| 61 73 20 61 20 5c 63 6f | 64 65 7b 70 72 69 6e 74 |as a \co|de{print|
|00000710| 7d 20 73 74 61 74 65 6d | 65 6e 74 2c 20 74 68 65 |} statem|ent, the|
|00000720| 0a 20 20 62 75 69 6c 74 | 2d 69 6e 20 5c 63 6f 64 |. built|-in \cod|
|00000730| 65 7b 6f 70 65 6e 28 29 | 7d 20 66 75 6e 63 74 69 |e{open()|} functi|
|00000740| 6f 6e 20 6f 72 20 61 20 | 6d 65 74 68 6f 64 20 6f |on or a |method o|
|00000750| 66 20 61 20 66 69 6c 65 | 20 6f 62 6a 65 63 74 29 |f a file| object)|
|00000760| 20 66 61 69 6c 73 0a 20 | 20 66 6f 72 20 61 6e 20 | fails. | for an |
|00000770| 49 2f 4f 2d 72 65 6c 61 | 74 65 64 20 72 65 61 73 |I/O-rela|ted reas|
|00000780| 6f 6e 2c 20 65 2e 67 2e | 2c 20 60 66 69 6c 65 20 |on, e.g.|, `file |
|00000790| 6e 6f 74 20 66 6f 75 6e | 64 27 2c 20 60 64 69 73 |not foun|d', `dis|
|000007a0| 6b 20 66 75 6c 6c 27 2e | 0a 5c 65 6e 64 7b 65 78 |k full'.|.\end{ex|
|000007b0| 63 64 65 73 63 7d 0a 0a | 5c 62 65 67 69 6e 7b 65 |cdesc}..|\begin{e|
|000007c0| 78 63 64 65 73 63 7d 7b | 49 6d 70 6f 72 74 45 72 |xcdesc}{|ImportEr|
|000007d0| 72 6f 72 7d 0a 25 20 58 | 58 58 4a 48 20 78 72 65 |ror}.% X|XXJH xre|
|000007e0| 66 20 74 6f 20 69 6d 70 | 6f 72 74 20 73 74 61 74 |f to imp|ort stat|
|000007f0| 65 6d 65 6e 74 3f 0a 20 | 20 52 61 69 73 65 64 20 |ement?. | Raised |
|00000800| 77 68 65 6e 20 61 6e 20 | 5c 63 6f 64 65 7b 69 6d |when an |\code{im|
|00000810| 70 6f 72 74 7d 20 73 74 | 61 74 65 6d 65 6e 74 20 |port} st|atement |
|00000820| 66 61 69 6c 73 20 74 6f | 20 66 69 6e 64 20 74 68 |fails to| find th|
|00000830| 65 20 6d 6f 64 75 6c 65 | 0a 20 20 64 65 66 69 6e |e module|. defin|
|00000840| 69 74 69 6f 6e 20 6f 72 | 20 77 68 65 6e 20 61 20 |ition or| when a |
|00000850| 5c 63 6f 64 65 7b 66 72 | 6f 6d 20 7b 5c 72 6d 20 |\code{fr|om {\rm |
|00000860| 5c 6c 64 6f 74 73 7d 20 | 69 6d 70 6f 72 74 7d 20 |\ldots} |import} |
|00000870| 66 61 69 6c 73 20 74 6f | 20 66 69 6e 64 20 61 0a |fails to| find a.|
|00000880| 20 20 6e 61 6d 65 20 74 | 68 61 74 20 69 73 20 74 | name t|hat is t|
|00000890| 6f 20 62 65 20 69 6d 70 | 6f 72 74 65 64 2e 0a 5c |o be imp|orted..\|
|000008a0| 65 6e 64 7b 65 78 63 64 | 65 73 63 7d 0a 0a 5c 62 |end{excd|esc}..\b|
|000008b0| 65 67 69 6e 7b 65 78 63 | 64 65 73 63 7d 7b 49 6e |egin{exc|desc}{In|
|000008c0| 64 65 78 45 72 72 6f 72 | 7d 0a 25 20 58 58 58 4a |dexError|}.% XXXJ|
|000008d0| 48 20 78 72 65 66 20 74 | 6f 20 73 65 71 75 65 6e |H xref t|o sequen|
|000008e0| 63 65 73 0a 20 20 52 61 | 69 73 65 64 20 77 68 65 |ces. Ra|ised whe|
|000008f0| 6e 20 61 20 73 65 71 75 | 65 6e 63 65 20 73 75 62 |n a sequ|ence sub|
|00000900| 73 63 72 69 70 74 20 69 | 73 20 6f 75 74 20 6f 66 |script i|s out of|
|00000910| 20 72 61 6e 67 65 2e 20 | 20 28 53 6c 69 63 65 20 | range. | (Slice |
|00000920| 69 6e 64 69 63 65 73 20 | 61 72 65 0a 20 20 73 69 |indices |are. si|
|00000930| 6c 65 6e 74 6c 79 20 74 | 72 75 6e 63 61 74 65 64 |lently t|runcated|
|00000940| 20 74 6f 20 66 61 6c 6c | 20 69 6e 20 74 68 65 20 | to fall| in the |
|00000950| 61 6c 6c 6f 77 65 64 20 | 72 61 6e 67 65 3b 20 69 |allowed |range; i|
|00000960| 66 20 61 6e 20 69 6e 64 | 65 78 20 69 73 20 6e 6f |f an ind|ex is no|
|00000970| 74 20 61 0a 20 20 70 6c | 61 69 6e 20 69 6e 74 65 |t a. pl|ain inte|
|00000980| 67 65 72 2c 20 5c 63 6f | 64 65 7b 54 79 70 65 45 |ger, \co|de{TypeE|
|00000990| 72 72 6f 72 7d 20 69 73 | 20 72 61 69 73 65 64 2e |rror} is| raised.|
|000009a0| 29 0a 5c 65 6e 64 7b 65 | 78 63 64 65 73 63 7d 0a |).\end{e|xcdesc}.|
|000009b0| 0a 5c 62 65 67 69 6e 7b | 65 78 63 64 65 73 63 7d |.\begin{|excdesc}|
|000009c0| 7b 4b 65 79 45 72 72 6f | 72 7d 0a 25 20 58 58 58 |{KeyErro|r}.% XXX|
|000009d0| 4a 48 20 78 72 65 66 20 | 74 6f 20 6d 61 70 70 69 |JH xref |to mappi|
|000009e0| 6e 67 20 6f 62 6a 65 63 | 74 73 3f 0a 20 20 52 61 |ng objec|ts?. Ra|
|000009f0| 69 73 65 64 20 77 68 65 | 6e 20 61 20 6d 61 70 70 |ised whe|n a mapp|
|00000a00| 69 6e 67 20 28 64 69 63 | 74 69 6f 6e 61 72 79 29 |ing (dic|tionary)|
|00000a10| 20 6b 65 79 20 69 73 20 | 6e 6f 74 20 66 6f 75 6e | key is |not foun|
|00000a20| 64 20 69 6e 20 74 68 65 | 20 73 65 74 20 6f 66 0a |d in the| set of.|
|00000a30| 20 20 65 78 69 73 74 69 | 6e 67 20 6b 65 79 73 2e | existi|ng keys.|
|00000a40| 0a 5c 65 6e 64 7b 65 78 | 63 64 65 73 63 7d 0a 0a |.\end{ex|cdesc}..|
|00000a50| 5c 62 65 67 69 6e 7b 65 | 78 63 64 65 73 63 7d 7b |\begin{e|xcdesc}{|
|00000a60| 4b 65 79 62 6f 61 72 64 | 49 6e 74 65 72 72 75 70 |Keyboard|Interrup|
|00000a70| 74 7d 0a 20 20 52 61 69 | 73 65 64 20 77 68 65 6e |t}. Rai|sed when|
|00000a80| 20 74 68 65 20 75 73 65 | 72 20 68 69 74 73 20 74 | the use|r hits t|
|00000a90| 68 65 20 69 6e 74 65 72 | 72 75 70 74 20 6b 65 79 |he inter|rupt key|
|00000aa0| 20 28 6e 6f 72 6d 61 6c | 6c 79 0a 20 20 5c 6b 62 | (normal|ly. \kb|
|00000ab0| 64 7b 43 6f 6e 74 72 6f | 6c 2d 43 7d 20 6f 72 0a |d{Contro|l-C} or.|
|00000ac0| 5c 6b 65 79 7b 44 45 4c | 7d 29 2e 20 20 44 75 72 |\key{DEL|}). Dur|
|00000ad0| 69 6e 67 20 65 78 65 63 | 75 74 69 6f 6e 2c 20 61 |ing exec|ution, a|
|00000ae0| 20 63 68 65 63 6b 20 66 | 6f 72 20 69 6e 74 65 72 | check f|or inter|
|00000af0| 72 75 70 74 73 20 69 73 | 20 6d 61 64 65 20 72 65 |rupts is| made re|
|00000b00| 67 75 6c 61 72 6c 79 2e | 0a 25 20 58 58 58 4a 48 |gularly.|.% XXXJH|
|00000b10| 20 78 72 65 66 73 20 68 | 65 72 65 0a 20 20 49 6e | xrefs h|ere. In|
|00000b20| 74 65 72 72 75 70 74 73 | 20 74 79 70 65 64 20 77 |terrupts| typed w|
|00000b30| 68 65 6e 20 61 20 62 75 | 69 6c 74 2d 69 6e 20 66 |hen a bu|ilt-in f|
|00000b40| 75 6e 63 74 69 6f 6e 20 | 5c 63 6f 64 65 7b 69 6e |unction |\code{in|
|00000b50| 70 75 74 28 29 7d 20 6f | 72 0a 20 20 5c 63 6f 64 |put()} o|r. \cod|
|00000b60| 65 7b 72 61 77 5f 69 6e | 70 75 74 28 29 7d 29 20 |e{raw_in|put()}) |
|00000b70| 69 73 20 77 61 69 74 69 | 6e 67 20 66 6f 72 20 69 |is waiti|ng for i|
|00000b80| 6e 70 75 74 20 61 6c 73 | 6f 20 72 61 69 73 65 20 |nput als|o raise |
|00000b90| 74 68 69 73 20 65 78 63 | 65 70 74 69 6f 6e 2e 20 |this exc|eption. |
|00000ba0| 20 4e 6f 0a 20 20 61 73 | 73 6f 63 69 61 74 65 64 | No. as|sociated|
|00000bb0| 20 76 61 6c 75 65 2e 0a | 5c 65 6e 64 7b 65 78 63 | value..|\end{exc|
|00000bc0| 64 65 73 63 7d 0a 0a 5c | 62 65 67 69 6e 7b 65 78 |desc}..\|begin{ex|
|00000bd0| 63 64 65 73 63 7d 7b 4d | 65 6d 6f 72 79 45 72 72 |cdesc}{M|emoryErr|
|00000be0| 6f 72 7d 0a 20 20 52 61 | 69 73 65 64 20 77 68 65 |or}. Ra|ised whe|
|00000bf0| 6e 20 61 6e 20 6f 70 65 | 72 61 74 69 6f 6e 20 72 |n an ope|ration r|
|00000c00| 75 6e 73 20 6f 75 74 20 | 6f 66 20 6d 65 6d 6f 72 |uns out |of memor|
|00000c10| 79 20 62 75 74 20 74 68 | 65 20 73 69 74 75 61 74 |y but th|e situat|
|00000c20| 69 6f 6e 20 6d 61 79 0a | 20 20 73 74 69 6c 6c 20 |ion may.| still |
|00000c30| 62 65 20 72 65 73 63 75 | 65 64 20 28 62 79 20 64 |be rescu|ed (by d|
|00000c40| 65 6c 65 74 69 6e 67 20 | 73 6f 6d 65 20 6f 62 6a |eleting |some obj|
|00000c50| 65 63 74 73 29 2e 20 20 | 54 68 65 20 61 73 73 6f |ects). |The asso|
|00000c60| 63 69 61 74 65 64 20 76 | 61 6c 75 65 20 69 73 0a |ciated v|alue is.|
|00000c70| 20 20 61 20 73 74 72 69 | 6e 67 20 69 6e 64 69 63 | a stri|ng indic|
|00000c80| 61 74 69 6e 67 20 77 68 | 61 74 20 6b 69 6e 64 20 |ating wh|at kind |
|00000c90| 6f 66 20 28 69 6e 74 65 | 72 6e 61 6c 29 20 6f 70 |of (inte|rnal) op|
|00000ca0| 65 72 61 74 69 6f 6e 20 | 72 61 6e 20 6f 75 74 20 |eration |ran out |
|00000cb0| 6f 66 20 6d 65 6d 6f 72 | 79 2e 0a 20 20 4e 6f 74 |of memor|y.. Not|
|00000cc0| 65 20 74 68 61 74 20 62 | 65 63 61 75 73 65 20 6f |e that b|ecause o|
|00000cd0| 66 20 74 68 65 20 75 6e | 64 65 72 6c 79 69 6e 67 |f the un|derlying|
|00000ce0| 20 6d 65 6d 6f 72 79 20 | 6d 61 6e 61 67 65 6d 65 | memory |manageme|
|00000cf0| 6e 74 20 61 72 63 68 69 | 74 65 63 74 75 72 65 0a |nt archi|tecture.|
|00000d00| 20 20 28 5c 43 7b 7d 27 | 73 20 5c 63 6f 64 65 7b | (\C{}'|s \code{|
|00000d10| 6d 61 6c 6c 6f 63 28 29 | 7d 20 66 75 6e 63 74 69 |malloc()|} functi|
|00000d20| 6f 6e 29 2c 20 74 68 65 | 20 69 6e 74 65 72 70 72 |on), the| interpr|
|00000d30| 65 74 65 72 20 6d 61 79 | 20 6e 6f 74 20 61 6c 77 |eter may| not alw|
|00000d40| 61 79 73 20 62 65 20 61 | 62 6c 65 0a 20 20 74 6f |ays be a|ble. to|
|00000d50| 20 63 6f 6d 70 6c 65 74 | 65 6c 79 20 72 65 63 6f | complet|ely reco|
|00000d60| 76 65 72 20 66 72 6f 6d | 20 74 68 69 73 20 73 69 |ver from| this si|
|00000d70| 74 75 61 74 69 6f 6e 3b | 20 69 74 20 6e 65 76 65 |tuation;| it neve|
|00000d80| 72 74 68 65 6c 65 73 73 | 20 72 61 69 73 65 73 20 |rtheless| raises |
|00000d90| 61 6e 0a 20 20 65 78 63 | 65 70 74 69 6f 6e 20 73 |an. exc|eption s|
|00000da0| 6f 20 74 68 61 74 20 61 | 20 73 74 61 63 6b 20 74 |o that a| stack t|
|00000db0| 72 61 63 65 62 61 63 6b | 20 63 61 6e 20 62 65 20 |raceback| can be |
|00000dc0| 70 72 69 6e 74 65 64 2c | 20 69 6e 20 63 61 73 65 |printed,| in case|
|00000dd0| 20 61 20 72 75 6e 2d 61 | 77 61 79 0a 20 20 70 72 | a run-a|way. pr|
|00000de0| 6f 67 72 61 6d 20 77 61 | 73 20 74 68 65 20 63 61 |ogram wa|s the ca|
|00000df0| 75 73 65 2e 0a 5c 65 6e | 64 7b 65 78 63 64 65 73 |use..\en|d{excdes|
|00000e00| 63 7d 0a 0a 5c 62 65 67 | 69 6e 7b 65 78 63 64 65 |c}..\beg|in{excde|
|00000e10| 73 63 7d 7b 4e 61 6d 65 | 45 72 72 6f 72 7d 0a 20 |sc}{Name|Error}. |
|00000e20| 20 52 61 69 73 65 64 20 | 77 68 65 6e 20 61 20 6c | Raised |when a l|
|00000e30| 6f 63 61 6c 20 6f 72 20 | 67 6c 6f 62 61 6c 20 6e |ocal or |global n|
|00000e40| 61 6d 65 20 69 73 20 6e | 6f 74 20 66 6f 75 6e 64 |ame is n|ot found|
|00000e50| 2e 20 20 54 68 69 73 20 | 61 70 70 6c 69 65 73 20 |. This |applies |
|00000e60| 6f 6e 6c 79 0a 20 20 74 | 6f 20 75 6e 71 75 61 6c |only. t|o unqual|
|00000e70| 69 66 69 65 64 20 6e 61 | 6d 65 73 2e 20 20 54 68 |ified na|mes. Th|
|00000e80| 65 20 61 73 73 6f 63 69 | 61 74 65 64 20 76 61 6c |e associ|ated val|
|00000e90| 75 65 20 69 73 20 74 68 | 65 20 6e 61 6d 65 20 74 |ue is th|e name t|
|00000ea0| 68 61 74 20 63 6f 75 6c | 64 0a 20 20 6e 6f 74 20 |hat coul|d. not |
|00000eb0| 62 65 20 66 6f 75 6e 64 | 2e 0a 5c 65 6e 64 7b 65 |be found|..\end{e|
|00000ec0| 78 63 64 65 73 63 7d 0a | 0a 5c 62 65 67 69 6e 7b |xcdesc}.|.\begin{|
|00000ed0| 65 78 63 64 65 73 63 7d | 7b 4f 76 65 72 66 6c 6f |excdesc}|{Overflo|
|00000ee0| 77 45 72 72 6f 72 7d 0a | 25 20 58 58 58 4a 48 20 |wError}.|% XXXJH |
|00000ef0| 72 65 66 65 72 65 6e 63 | 65 20 74 6f 20 6c 6f 6e |referenc|e to lon|
|00000f00| 67 27 73 20 61 6e 64 2f | 6f 72 20 69 6e 74 27 73 |g's and/|or int's|
|00000f10| 3f 0a 20 20 52 61 69 73 | 65 64 20 77 68 65 6e 20 |?. Rais|ed when |
|00000f20| 74 68 65 20 72 65 73 75 | 6c 74 20 6f 66 20 61 6e |the resu|lt of an|
|00000f30| 20 61 72 69 74 68 6d 65 | 74 69 63 20 6f 70 65 72 | arithme|tic oper|
|00000f40| 61 74 69 6f 6e 20 69 73 | 20 74 6f 6f 20 6c 61 72 |ation is| too lar|
|00000f50| 67 65 20 74 6f 20 62 65 | 0a 20 20 72 65 70 72 65 |ge to be|. repre|
|00000f60| 73 65 6e 74 65 64 2e 20 | 20 54 68 69 73 20 63 61 |sented. | This ca|
|00000f70| 6e 6e 6f 74 20 6f 63 63 | 75 72 20 66 6f 72 20 6c |nnot occ|ur for l|
|00000f80| 6f 6e 67 20 69 6e 74 65 | 67 65 72 73 20 28 77 68 |ong inte|gers (wh|
|00000f90| 69 63 68 20 77 6f 75 6c | 64 20 72 61 74 68 65 72 |ich woul|d rather|
|00000fa0| 0a 20 20 72 61 69 73 65 | 20 5c 63 6f 64 65 7b 4d |. raise| \code{M|
|00000fb0| 65 6d 6f 72 79 45 72 72 | 6f 72 7d 20 74 68 61 6e |emoryErr|or} than|
|00000fc0| 20 67 69 76 65 20 75 70 | 29 2e 20 20 42 65 63 61 | give up|). Beca|
|00000fd0| 75 73 65 20 6f 66 20 74 | 68 65 20 6c 61 63 6b 20 |use of t|he lack |
|00000fe0| 6f 66 0a 20 20 73 74 61 | 6e 64 61 72 64 69 7a 61 |of. sta|ndardiza|
|00000ff0| 74 69 6f 6e 20 6f 66 20 | 66 6c 6f 61 74 69 6e 67 |tion of |floating|
|00001000| 20 70 6f 69 6e 74 20 65 | 78 63 65 70 74 69 6f 6e | point e|xception|
|00001010| 20 68 61 6e 64 6c 69 6e | 67 20 69 6e 20 5c 43 7b | handlin|g in \C{|
|00001020| 7d 2c 20 6d 6f 73 74 0a | 20 20 66 6c 6f 61 74 69 |}, most.| floati|
|00001030| 6e 67 20 70 6f 69 6e 74 | 20 6f 70 65 72 61 74 69 |ng point| operati|
|00001040| 6f 6e 73 20 61 6c 73 6f | 20 61 72 65 6e 27 74 20 |ons also| aren't |
|00001050| 63 68 65 63 6b 65 64 2e | 20 20 46 6f 72 20 70 6c |checked.| For pl|
|00001060| 61 69 6e 20 69 6e 74 65 | 67 65 72 73 2c 0a 20 20 |ain inte|gers,. |
|00001070| 61 6c 6c 20 6f 70 65 72 | 61 74 69 6f 6e 73 20 74 |all oper|ations t|
|00001080| 68 61 74 20 63 61 6e 20 | 6f 76 65 72 66 6c 6f 77 |hat can |overflow|
|00001090| 20 61 72 65 20 63 68 65 | 63 6b 65 64 20 65 78 63 | are che|cked exc|
|000010a0| 65 70 74 20 6c 65 66 74 | 20 73 68 69 66 74 2c 20 |ept left| shift, |
|000010b0| 77 68 65 72 65 0a 20 20 | 74 79 70 69 63 61 6c 20 |where. |typical |
|000010c0| 61 70 70 6c 69 63 61 74 | 69 6f 6e 73 20 70 72 65 |applicat|ions pre|
|000010d0| 66 65 72 20 74 6f 20 64 | 72 6f 70 20 62 69 74 73 |fer to d|rop bits|
|000010e0| 20 74 68 61 6e 20 72 61 | 69 73 65 20 61 6e 20 65 | than ra|ise an e|
|000010f0| 78 63 65 70 74 69 6f 6e | 2e 0a 5c 65 6e 64 7b 65 |xception|..\end{e|
|00001100| 78 63 64 65 73 63 7d 0a | 0a 5c 62 65 67 69 6e 7b |xcdesc}.|.\begin{|
|00001110| 65 78 63 64 65 73 63 7d | 7b 52 75 6e 74 69 6d 65 |excdesc}|{Runtime|
|00001120| 45 72 72 6f 72 7d 0a 20 | 20 52 61 69 73 65 64 20 |Error}. | Raised |
|00001130| 77 68 65 6e 20 61 6e 20 | 65 72 72 6f 72 20 69 73 |when an |error is|
|00001140| 20 64 65 74 65 63 74 65 | 64 20 74 68 61 74 20 64 | detecte|d that d|
|00001150| 6f 65 73 6e 27 74 20 66 | 61 6c 6c 20 69 6e 20 61 |oesn't f|all in a|
|00001160| 6e 79 20 6f 66 20 74 68 | 65 0a 20 20 6f 74 68 65 |ny of th|e. othe|
|00001170| 72 20 63 61 74 65 67 6f | 72 69 65 73 2e 20 20 54 |r catego|ries. T|
|00001180| 68 65 20 61 73 73 6f 63 | 69 61 74 65 64 20 76 61 |he assoc|iated va|
|00001190| 6c 75 65 20 69 73 20 61 | 20 73 74 72 69 6e 67 20 |lue is a| string |
|000011a0| 69 6e 64 69 63 61 74 69 | 6e 67 20 77 68 61 74 0a |indicati|ng what.|
|000011b0| 20 20 70 72 65 63 69 73 | 65 6c 79 20 77 65 6e 74 | precis|ely went|
|000011c0| 20 77 72 6f 6e 67 2e 20 | 20 28 54 68 69 73 20 65 | wrong. | (This e|
|000011d0| 78 63 65 70 74 69 6f 6e | 20 69 73 20 61 20 72 65 |xception| is a re|
|000011e0| 6c 69 63 20 66 72 6f 6d | 20 61 20 70 72 65 76 69 |lic from| a previ|
|000011f0| 6f 75 73 0a 20 20 76 65 | 72 73 69 6f 6e 20 6f 66 |ous. ve|rsion of|
|00001200| 20 74 68 65 20 69 6e 74 | 65 72 70 72 65 74 65 72 | the int|erpreter|
|00001210| 3b 20 69 74 20 69 73 20 | 6e 6f 74 20 75 73 65 64 |; it is |not used|
|00001220| 20 61 6e 79 20 6d 6f 72 | 65 20 65 78 63 65 70 74 | any mor|e except|
|00001230| 20 62 79 20 73 6f 6d 65 | 0a 20 20 65 78 74 65 6e | by some|. exten|
|00001240| 73 69 6f 6e 20 6d 6f 64 | 75 6c 65 73 20 74 68 61 |sion mod|ules tha|
|00001250| 74 20 68 61 76 65 6e 27 | 74 20 62 65 65 6e 20 63 |t haven'|t been c|
|00001260| 6f 6e 76 65 72 74 65 64 | 20 74 6f 20 64 65 66 69 |onverted| to defi|
|00001270| 6e 65 20 74 68 65 69 72 | 20 6f 77 6e 0a 20 20 65 |ne their| own. e|
|00001280| 78 63 65 70 74 69 6f 6e | 73 20 79 65 74 2e 29 0a |xception|s yet.).|
|00001290| 5c 65 6e 64 7b 65 78 63 | 64 65 73 63 7d 0a 0a 5c |\end{exc|desc}..\|
|000012a0| 62 65 67 69 6e 7b 65 78 | 63 64 65 73 63 7d 7b 53 |begin{ex|cdesc}{S|
|000012b0| 79 6e 74 61 78 45 72 72 | 6f 72 7d 0a 25 20 58 58 |yntaxErr|or}.% XX|
|000012c0| 58 4a 48 20 78 72 65 66 | 20 74 6f 20 74 68 65 73 |XJH xref| to thes|
|000012d0| 65 20 66 75 6e 63 74 69 | 6f 6e 73 3f 0a 20 20 52 |e functi|ons?. R|
|000012e0| 61 69 73 65 64 20 77 68 | 65 6e 20 74 68 65 20 70 |aised wh|en the p|
|000012f0| 61 72 73 65 72 20 65 6e | 63 6f 75 6e 74 65 72 73 |arser en|counters|
|00001300| 20 61 20 73 79 6e 74 61 | 78 20 65 72 72 6f 72 2e | a synta|x error.|
|00001310| 20 20 54 68 69 73 20 6d | 61 79 20 6f 63 63 75 72 | This m|ay occur|
|00001320| 20 69 6e 0a 20 20 61 6e | 20 5c 63 6f 64 65 7b 69 | in. an| \code{i|
|00001330| 6d 70 6f 72 74 7d 20 73 | 74 61 74 65 6d 65 6e 74 |mport} s|tatement|
|00001340| 2c 20 69 6e 20 61 6e 20 | 5c 63 6f 64 65 7b 65 78 |, in an |\code{ex|
|00001350| 65 63 7d 20 73 74 61 74 | 65 6d 65 6e 74 2c 20 69 |ec} stat|ement, i|
|00001360| 6e 20 61 20 63 61 6c 6c | 0a 20 20 74 6f 20 74 68 |n a call|. to th|
|00001370| 65 20 62 75 69 6c 74 2d | 69 6e 20 66 75 6e 63 74 |e built-|in funct|
|00001380| 69 6f 6e 20 5c 63 6f 64 | 65 7b 65 76 61 6c 28 29 |ion \cod|e{eval()|
|00001390| 7d 20 6f 72 20 5c 63 6f | 64 65 7b 69 6e 70 75 74 |} or \co|de{input|
|000013a0| 28 29 7d 2c 20 6f 72 0a | 20 20 77 68 65 6e 20 72 |()}, or.| when r|
|000013b0| 65 61 64 69 6e 67 20 74 | 68 65 20 69 6e 69 74 69 |eading t|he initi|
|000013c0| 61 6c 20 73 63 72 69 70 | 74 20 6f 72 20 73 74 61 |al scrip|t or sta|
|000013d0| 6e 64 61 72 64 20 69 6e | 70 75 74 20 28 61 6c 73 |ndard in|put (als|
|000013e0| 6f 0a 20 20 69 6e 74 65 | 72 61 63 74 69 76 65 6c |o. inte|ractivel|
|000013f0| 79 29 2e 0a 5c 65 6e 64 | 7b 65 78 63 64 65 73 63 |y)..\end|{excdesc|
|00001400| 7d 0a 0a 5c 62 65 67 69 | 6e 7b 65 78 63 64 65 73 |}..\begi|n{excdes|
|00001410| 63 7d 7b 53 79 73 74 65 | 6d 45 72 72 6f 72 7d 0a |c}{Syste|mError}.|
|00001420| 20 20 52 61 69 73 65 64 | 20 77 68 65 6e 20 74 68 | Raised| when th|
|00001430| 65 20 69 6e 74 65 72 70 | 72 65 74 65 72 20 66 69 |e interp|reter fi|
|00001440| 6e 64 73 20 61 6e 20 69 | 6e 74 65 72 6e 61 6c 20 |nds an i|nternal |
|00001450| 65 72 72 6f 72 2c 20 62 | 75 74 20 74 68 65 0a 20 |error, b|ut the. |
|00001460| 20 73 69 74 75 61 74 69 | 6f 6e 20 64 6f 65 73 20 | situati|on does |
|00001470| 6e 6f 74 20 6c 6f 6f 6b | 20 73 6f 20 73 65 72 69 |not look| so seri|
|00001480| 6f 75 73 20 74 6f 20 63 | 61 75 73 65 20 69 74 20 |ous to c|ause it |
|00001490| 74 6f 20 61 62 61 6e 64 | 6f 6e 20 61 6c 6c 20 68 |to aband|on all h|
|000014a0| 6f 70 65 2e 0a 20 20 54 | 68 65 20 61 73 73 6f 63 |ope.. T|he assoc|
|000014b0| 69 61 74 65 64 20 76 61 | 6c 75 65 20 69 73 20 61 |iated va|lue is a|
|000014c0| 20 73 74 72 69 6e 67 20 | 69 6e 64 69 63 61 74 69 | string |indicati|
|000014d0| 6e 67 20 77 68 61 74 20 | 77 65 6e 74 20 77 72 6f |ng what |went wro|
|000014e0| 6e 67 20 28 69 6e 0a 20 | 20 6c 6f 77 2d 6c 65 76 |ng (in. | low-lev|
|000014f0| 65 6c 20 74 65 72 6d 73 | 29 2e 0a 20 20 0a 20 20 |el terms|).. . |
|00001500| 59 6f 75 20 73 68 6f 75 | 6c 64 20 72 65 70 6f 72 |You shou|ld repor|
|00001510| 74 20 74 68 69 73 20 74 | 6f 20 74 68 65 20 61 75 |t this t|o the au|
|00001520| 74 68 6f 72 20 6f 72 20 | 6d 61 69 6e 74 61 69 6e |thor or |maintain|
|00001530| 65 72 20 6f 66 20 79 6f | 75 72 20 50 79 74 68 6f |er of yo|ur Pytho|
|00001540| 6e 0a 20 20 69 6e 74 65 | 72 70 72 65 74 65 72 2e |n. inte|rpreter.|
|00001550| 20 20 42 65 20 73 75 72 | 65 20 74 6f 20 72 65 70 | Be sur|e to rep|
|00001560| 6f 72 74 20 74 68 65 20 | 76 65 72 73 69 6f 6e 20 |ort the |version |
|00001570| 73 74 72 69 6e 67 20 6f | 66 20 74 68 65 20 50 79 |string o|f the Py|
|00001580| 74 68 6f 6e 0a 20 20 69 | 6e 74 65 72 70 72 65 74 |thon. i|nterpret|
|00001590| 65 72 20 28 5c 63 6f 64 | 65 7b 73 79 73 2e 76 65 |er (\cod|e{sys.ve|
|000015a0| 72 73 69 6f 6e 7d 3b 20 | 69 74 20 69 73 20 61 6c |rsion}; |it is al|
|000015b0| 73 6f 20 70 72 69 6e 74 | 65 64 20 61 74 20 74 68 |so print|ed at th|
|000015c0| 65 20 73 74 61 72 74 20 | 6f 66 20 61 6e 0a 20 20 |e start |of an. |
|000015d0| 69 6e 74 65 72 61 63 74 | 69 76 65 20 50 79 74 68 |interact|ive Pyth|
|000015e0| 6f 6e 20 73 65 73 73 69 | 6f 6e 29 2c 20 74 68 65 |on sessi|on), the|
|000015f0| 20 65 78 61 63 74 20 65 | 72 72 6f 72 20 6d 65 73 | exact e|rror mes|
|00001600| 73 61 67 65 20 28 74 68 | 65 20 65 78 63 65 70 74 |sage (th|e except|
|00001610| 69 6f 6e 27 73 0a 20 20 | 61 73 73 6f 63 69 61 74 |ion's. |associat|
|00001620| 65 64 20 76 61 6c 75 65 | 29 20 61 6e 64 20 69 66 |ed value|) and if|
|00001630| 20 70 6f 73 73 69 62 6c | 65 20 74 68 65 20 73 6f | possibl|e the so|
|00001640| 75 72 63 65 20 6f 66 20 | 74 68 65 20 70 72 6f 67 |urce of |the prog|
|00001650| 72 61 6d 20 74 68 61 74 | 0a 20 20 74 72 69 67 67 |ram that|. trigg|
|00001660| 65 72 65 64 20 74 68 65 | 20 65 72 72 6f 72 2e 0a |ered the| error..|
|00001670| 5c 65 6e 64 7b 65 78 63 | 64 65 73 63 7d 0a 0a 5c |\end{exc|desc}..\|
|00001680| 62 65 67 69 6e 7b 65 78 | 63 64 65 73 63 7d 7b 53 |begin{ex|cdesc}{S|
|00001690| 79 73 74 65 6d 45 78 69 | 74 7d 0a 25 20 58 58 58 |ystemExi|t}.% XXX|
|000016a0| 4a 48 20 78 72 65 66 20 | 74 6f 20 6d 6f 64 75 6c |JH xref |to modul|
|000016b0| 65 20 73 79 73 3f 0a 20 | 20 54 68 69 73 20 65 78 |e sys?. | This ex|
|000016c0| 63 65 70 74 69 6f 6e 20 | 69 73 20 72 61 69 73 65 |ception |is raise|
|000016d0| 64 20 62 79 20 74 68 65 | 20 5c 63 6f 64 65 7b 73 |d by the| \code{s|
|000016e0| 79 73 2e 65 78 69 74 28 | 29 7d 20 66 75 6e 63 74 |ys.exit(|)} funct|
|000016f0| 69 6f 6e 2e 20 20 57 68 | 65 6e 20 69 74 0a 20 20 |ion. Wh|en it. |
|00001700| 69 73 20 6e 6f 74 20 68 | 61 6e 64 6c 65 64 2c 20 |is not h|andled, |
|00001710| 74 68 65 20 50 79 74 68 | 6f 6e 20 69 6e 74 65 72 |the Pyth|on inter|
|00001720| 70 72 65 74 65 72 20 65 | 78 69 74 73 3b 20 6e 6f |preter e|xits; no|
|00001730| 20 73 74 61 63 6b 20 74 | 72 61 63 65 62 61 63 6b | stack t|raceback|
|00001740| 20 69 73 0a 20 20 70 72 | 69 6e 74 65 64 2e 20 20 | is. pr|inted. |
|00001750| 49 66 20 74 68 65 20 61 | 73 73 6f 63 69 61 74 65 |If the a|ssociate|
|00001760| 64 20 76 61 6c 75 65 20 | 69 73 20 61 20 70 6c 61 |d value |is a pla|
|00001770| 69 6e 20 69 6e 74 65 67 | 65 72 2c 20 69 74 20 73 |in integ|er, it s|
|00001780| 70 65 63 69 66 69 65 73 | 20 74 68 65 0a 20 20 73 |pecifies| the. s|
|00001790| 79 73 74 65 6d 20 65 78 | 69 74 20 73 74 61 74 75 |ystem ex|it statu|
|000017a0| 73 20 28 70 61 73 73 65 | 64 20 74 6f 20 5c 43 7b |s (passe|d to \C{|
|000017b0| 7d 27 73 20 5c 63 6f 64 | 65 7b 65 78 69 74 28 29 |}'s \cod|e{exit()|
|000017c0| 7d 20 66 75 6e 63 74 69 | 6f 6e 29 3b 20 69 66 20 |} functi|on); if |
|000017d0| 69 74 20 69 73 0a 20 20 | 5c 63 6f 64 65 7b 4e 6f |it is. |\code{No|
|000017e0| 6e 65 7d 2c 20 74 68 65 | 20 65 78 69 74 20 73 74 |ne}, the| exit st|
|000017f0| 61 74 75 73 20 69 73 20 | 7a 65 72 6f 3b 20 69 66 |atus is |zero; if|
|00001800| 20 69 74 20 68 61 73 20 | 61 6e 6f 74 68 65 72 20 | it has |another |
|00001810| 74 79 70 65 20 28 73 75 | 63 68 20 61 73 0a 20 20 |type (su|ch as. |
|00001820| 61 20 73 74 72 69 6e 67 | 29 2c 20 74 68 65 20 6f |a string|), the o|
|00001830| 62 6a 65 63 74 27 73 20 | 76 61 6c 75 65 20 69 73 |bject's |value is|
|00001840| 20 70 72 69 6e 74 65 64 | 20 61 6e 64 20 74 68 65 | printed| and the|
|00001850| 20 65 78 69 74 20 73 74 | 61 74 75 73 20 69 73 20 | exit st|atus is |
|00001860| 6f 6e 65 2e 0a 20 20 0a | 20 20 41 20 63 61 6c 6c |one.. .| A call|
|00001870| 20 74 6f 20 5c 63 6f 64 | 65 7b 73 79 73 2e 65 78 | to \cod|e{sys.ex|
|00001880| 69 74 7d 20 69 73 20 74 | 72 61 6e 73 6c 61 74 65 |it} is t|ranslate|
|00001890| 64 20 69 6e 74 6f 20 61 | 6e 20 65 78 63 65 70 74 |d into a|n except|
|000018a0| 69 6f 6e 20 73 6f 20 74 | 68 61 74 0a 20 20 63 6c |ion so t|hat. cl|
|000018b0| 65 61 6e 2d 75 70 20 68 | 61 6e 64 6c 65 72 73 20 |ean-up h|andlers |
|000018c0| 28 5c 63 6f 64 65 7b 66 | 69 6e 61 6c 6c 79 7d 20 |(\code{f|inally} |
|000018d0| 63 6c 61 75 73 65 73 20 | 6f 66 20 5c 63 6f 64 65 |clauses |of \code|
|000018e0| 7b 74 72 79 7d 20 73 74 | 61 74 65 6d 65 6e 74 73 |{try} st|atements|
|000018f0| 29 0a 20 20 63 61 6e 20 | 62 65 20 65 78 65 63 75 |). can |be execu|
|00001900| 74 65 64 2c 20 61 6e 64 | 20 73 6f 20 74 68 61 74 |ted, and| so that|
|00001910| 20 61 20 64 65 62 75 67 | 67 65 72 20 63 61 6e 20 | a debug|ger can |
|00001920| 65 78 65 63 75 74 65 20 | 61 20 73 63 72 69 70 74 |execute |a script|
|00001930| 20 77 69 74 68 6f 75 74 | 0a 20 20 72 75 6e 6e 69 | without|. runni|
|00001940| 6e 67 20 74 68 65 20 72 | 69 73 6b 20 6f 66 20 6c |ng the r|isk of l|
|00001950| 6f 73 69 6e 67 20 63 6f | 6e 74 72 6f 6c 2e 20 20 |osing co|ntrol. |
|00001960| 54 68 65 20 5c 63 6f 64 | 65 7b 70 6f 73 69 78 2e |The \cod|e{posix.|
|00001970| 5f 65 78 69 74 28 29 7d | 20 66 75 6e 63 74 69 6f |_exit()}| functio|
|00001980| 6e 0a 20 20 63 61 6e 20 | 62 65 20 75 73 65 64 20 |n. can |be used |
|00001990| 69 66 20 69 74 20 69 73 | 20 61 62 73 6f 6c 75 74 |if it is| absolut|
|000019a0| 65 6c 79 20 70 6f 73 69 | 74 69 76 65 6c 79 20 6e |ely posi|tively n|
|000019b0| 65 63 65 73 73 61 72 79 | 20 74 6f 20 65 78 69 74 |ecessary| to exit|
|000019c0| 0a 20 20 69 6d 6d 65 64 | 69 61 74 65 6c 79 20 28 |. immed|iately (|
|000019d0| 65 2e 67 2e 2c 20 61 66 | 74 65 72 20 61 20 5c 63 |e.g., af|ter a \c|
|000019e0| 6f 64 65 7b 66 6f 72 6b | 28 29 7d 20 69 6e 20 74 |ode{fork|()} in t|
|000019f0| 68 65 20 63 68 69 6c 64 | 20 70 72 6f 63 65 73 73 |he child| process|
|00001a00| 29 2e 0a 5c 65 6e 64 7b | 65 78 63 64 65 73 63 7d |)..\end{|excdesc}|
|00001a10| 0a 0a 5c 62 65 67 69 6e | 7b 65 78 63 64 65 73 63 |..\begin|{excdesc|
|00001a20| 7d 7b 54 79 70 65 45 72 | 72 6f 72 7d 0a 20 20 52 |}{TypeEr|ror}. R|
|00001a30| 61 69 73 65 64 20 77 68 | 65 6e 20 61 20 62 75 69 |aised wh|en a bui|
|00001a40| 6c 74 2d 69 6e 20 6f 70 | 65 72 61 74 69 6f 6e 20 |lt-in op|eration |
|00001a50| 6f 72 20 66 75 6e 63 74 | 69 6f 6e 20 69 73 20 61 |or funct|ion is a|
|00001a60| 70 70 6c 69 65 64 20 74 | 6f 20 61 6e 20 6f 62 6a |pplied t|o an obj|
|00001a70| 65 63 74 0a 20 20 6f 66 | 20 69 6e 61 70 70 72 6f |ect. of| inappro|
|00001a80| 70 72 69 61 74 65 20 74 | 79 70 65 2e 20 20 54 68 |priate t|ype. Th|
|00001a90| 65 20 61 73 73 6f 63 69 | 61 74 65 64 20 76 61 6c |e associ|ated val|
|00001aa0| 75 65 20 69 73 20 61 20 | 73 74 72 69 6e 67 20 67 |ue is a |string g|
|00001ab0| 69 76 69 6e 67 0a 20 20 | 64 65 74 61 69 6c 73 20 |iving. |details |
|00001ac0| 61 62 6f 75 74 20 74 68 | 65 20 74 79 70 65 20 6d |about th|e type m|
|00001ad0| 69 73 6d 61 74 63 68 2e | 0a 5c 65 6e 64 7b 65 78 |ismatch.|.\end{ex|
|00001ae0| 63 64 65 73 63 7d 0a 0a | 5c 62 65 67 69 6e 7b 65 |cdesc}..|\begin{e|
|00001af0| 78 63 64 65 73 63 7d 7b | 56 61 6c 75 65 45 72 72 |xcdesc}{|ValueErr|
|00001b00| 6f 72 7d 0a 20 20 52 61 | 69 73 65 64 20 77 68 65 |or}. Ra|ised whe|
|00001b10| 6e 20 61 20 62 75 69 6c | 74 2d 69 6e 20 6f 70 65 |n a buil|t-in ope|
|00001b20| 72 61 74 69 6f 6e 20 6f | 72 20 66 75 6e 63 74 69 |ration o|r functi|
|00001b30| 6f 6e 20 72 65 63 65 69 | 76 65 73 20 61 6e 20 61 |on recei|ves an a|
|00001b40| 72 67 75 6d 65 6e 74 0a | 20 20 74 68 61 74 20 68 |rgument.| that h|
|00001b50| 61 73 20 74 68 65 20 72 | 69 67 68 74 20 74 79 70 |as the r|ight typ|
|00001b60| 65 20 62 75 74 20 61 6e | 20 69 6e 61 70 70 72 6f |e but an| inappro|
|00001b70| 70 72 69 61 74 65 20 76 | 61 6c 75 65 2c 20 61 6e |priate v|alue, an|
|00001b80| 64 20 74 68 65 0a 20 20 | 73 69 74 75 61 74 69 6f |d the. |situatio|
|00001b90| 6e 20 69 73 20 6e 6f 74 | 20 64 65 73 63 72 69 62 |n is not| describ|
|00001ba0| 65 64 20 62 79 20 61 20 | 6d 6f 72 65 20 70 72 65 |ed by a |more pre|
|00001bb0| 63 69 73 65 20 65 78 63 | 65 70 74 69 6f 6e 20 73 |cise exc|eption s|
|00001bc0| 75 63 68 20 61 73 0a 20 | 20 5c 63 6f 64 65 7b 49 |uch as. | \code{I|
|00001bd0| 6e 64 65 78 45 72 72 6f | 72 7d 2e 0a 5c 65 6e 64 |ndexErro|r}..\end|
|00001be0| 7b 65 78 63 64 65 73 63 | 7d 0a 0a 5c 62 65 67 69 |{excdesc|}..\begi|
|00001bf0| 6e 7b 65 78 63 64 65 73 | 63 7d 7b 5a 65 72 6f 44 |n{excdes|c}{ZeroD|
|00001c00| 69 76 69 73 69 6f 6e 45 | 72 72 6f 72 7d 0a 20 20 |ivisionE|rror}. |
|00001c10| 52 61 69 73 65 64 20 77 | 68 65 6e 20 74 68 65 20 |Raised w|hen the |
|00001c20| 73 65 63 6f 6e 64 20 61 | 72 67 75 6d 65 6e 74 20 |second a|rgument |
|00001c30| 6f 66 20 61 20 64 69 76 | 69 73 69 6f 6e 20 6f 72 |of a div|ision or|
|00001c40| 20 6d 6f 64 75 6c 6f 20 | 6f 70 65 72 61 74 69 6f | modulo |operatio|
|00001c50| 6e 20 69 73 0a 20 20 7a | 65 72 6f 2e 20 20 54 68 |n is. z|ero. Th|
|00001c60| 65 20 61 73 73 6f 63 69 | 61 74 65 64 20 76 61 6c |e associ|ated val|
|00001c70| 75 65 20 69 73 20 61 20 | 73 74 72 69 6e 67 20 69 |ue is a |string i|
|00001c80| 6e 64 69 63 61 74 69 6e | 67 20 74 68 65 20 74 79 |ndicatin|g the ty|
|00001c90| 70 65 20 6f 66 20 74 68 | 65 0a 20 20 6f 70 65 72 |pe of th|e. oper|
|00001ca0| 61 6e 64 73 20 61 6e 64 | 20 74 68 65 20 6f 70 65 |ands and| the ope|
|00001cb0| 72 61 74 69 6f 6e 2e 0a | 5c 65 6e 64 7b 65 78 63 |ration..|\end{exc|
|00001cc0| 64 65 73 63 7d 0a | |desc}. | |
+--------+-------------------------+-------------------------+--------+--------+