%!PS-Adobe-2.0
%%Creator: dvips(k) 5.96.1 Copyright 2007 Radical Eye Software
%%Title: paper-letter/ref.dvi
%%CreationDate: Fri Dec 19 16:19:41 2008
%%Pages: 101
%%PageOrder: Ascend
%%BoundingBox: 0 0 612 792
%%DocumentFonts: Helvetica Helvetica-Oblique Times-Roman Times-Bold
%%+ CMSY10 Times-Italic Courier Helvetica-Bold CMSY5 Courier-Bold
%%DocumentPaperSizes: Letter
%%EndComments
%DVIPSWebPage: (www.radicaleye.com)
%DVIPSCommandLine: dvips -N0 -t letter -o paper-letter/ref.ps
%+ paper-letter/ref.dvi
%DVIPSParameters: dpi=600
%DVIPSSource: TeX output 2008.12.19:1619
%%BeginProcSet: tex.pro 0 0
%!
/TeXDict 300 dict def TeXDict begin/N{def}def/B{bind def}N/S{exch}N/X{S
N}B/A{dup}B/TR{translate}N/isls false N/vsize 11 72 mul N/hsize 8.5 72
mul N/landplus90{false}def/@rigin{isls{[0 landplus90{1 -1}{-1 1}ifelse 0
0 0]concat}if 72 Resolution div 72 VResolution div neg scale isls{
landplus90{VResolution 72 div vsize mul 0 exch}{Resolution -72 div hsize
mul 0}ifelse TR}if Resolution VResolution vsize -72 div 1 add mul TR[
matrix currentmatrix{A A round sub abs 0.00001 lt{round}if}forall round
exch round exch]setmatrix}N/@landscape{/isls true N}B/@manualfeed{
statusdict/manualfeed true put}B/@copies{/#copies X}B/FMat[1 0 0 -1 0 0]
N/FBB[0 0 0 0]N/nn 0 N/IEn 0 N/ctr 0 N/df-tail{/nn 8 dict N nn begin
/FontType 3 N/FontMatrix fntrx N/FontBBox FBB N string/base X array
/BitMaps X/BuildChar{CharBuilder}N/Encoding IEn N end A{/foo setfont}2
array copy cvx N load 0 nn put/ctr 0 N[}B/sf 0 N/df{/sf 1 N/fntrx FMat N
df-tail}B/dfs{div/sf X/fntrx[sf 0 0 sf neg 0 0]N df-tail}B/E{pop nn A
definefont setfont}B/Cw{Cd A length 5 sub get}B/Ch{Cd A length 4 sub get
}B/Cx{128 Cd A length 3 sub get sub}B/Cy{Cd A length 2 sub get 127 sub}
B/Cdx{Cd A length 1 sub get}B/Ci{Cd A type/stringtype ne{ctr get/ctr ctr
1 add N}if}B/CharBuilder{save 3 1 roll S A/base get 2 index get S
/BitMaps get S get/Cd X pop/ctr 0 N Cdx 0 Cx Cy Ch sub Cx Cw add Cy
setcachedevice Cw Ch true[1 0 0 -1 -.1 Cx sub Cy .1 sub]{Ci}imagemask
restore}B/D{/cc X A type/stringtype ne{]}if nn/base get cc ctr put nn
/BitMaps get S ctr S sf 1 ne{A A length 1 sub A 2 index S get sf div put
}if put/ctr ctr 1 add N}B/I{cc 1 add D}B/bop{userdict/bop-hook known{
bop-hook}if/SI save N @rigin 0 0 moveto/V matrix currentmatrix A 1 get A
mul exch 0 get A mul add .99 lt{/QV}{/RV}ifelse load def pop pop}N/eop{
SI restore userdict/eop-hook known{eop-hook}if showpage}N/@start{
userdict/start-hook known{start-hook}if pop/VResolution X/Resolution X
1000 div/DVImag X/IEn 256 array N 2 string 0 1 255{IEn S A 360 add 36 4
index cvrs cvn put}for pop 65781.76 div/vsize X 65781.76 div/hsize X}N
/p{show}N/RMat[1 0 0 -1 0 0]N/BDot 260 string N/Rx 0 N/Ry 0 N/V{}B/RV/v{
/Ry X/Rx X V}B statusdict begin/product where{pop false[(Display)(NeXT)
(LaserWriter 16/600)]{A length product length le{A length product exch 0
exch getinterval eq{pop true exit}if}{pop}ifelse}forall}{false}ifelse
end{{gsave TR -.1 .1 TR 1 1 scale Rx Ry false RMat{BDot}imagemask
grestore}}{{gsave TR -.1 .1 TR Rx Ry scale 1 1 false RMat{BDot}
imagemask grestore}}ifelse B/QV{gsave newpath transform round exch round
exch itransform moveto Rx 0 rlineto 0 Ry neg rlineto Rx neg 0 rlineto
fill grestore}B/a{moveto}B/delta 0 N/tail{A/delta X 0 rmoveto}B/M{S p
delta add tail}B/b{S p tail}B/c{-4 M}B/d{-3 M}B/e{-2 M}B/f{-1 M}B/g{0 M}
B/h{1 M}B/i{2 M}B/j{3 M}B/k{4 M}B/w{0 rmoveto}B/l{p -4 w}B/m{p -3 w}B/n{
p -2 w}B/o{p -1 w}B/q{p 1 w}B/r{p 2 w}B/s{p 3 w}B/t{p 4 w}B/x{0 S
rmoveto}B/y{3 2 roll p a}B/bos{/SS save N}B/eos{SS restore}B end
%%EndProcSet
%%BeginProcSet: 8r.enc 0 0
% File 8r.enc TeX Base 1 Encoding Revision 2.0 2002-10-30
%
% @@psencodingfile@{
% author = "S. Rahtz, P. MacKay, Alan Jeffrey, B. Horn, K. Berry,
% W. Schmidt, P. Lehman",
% version = "2.0",
% date = "27nov06",
% filename = "8r.enc",
% email = "tex-fonts@@tug.org",
% docstring = "This is the encoding vector for Type1 and TrueType
% fonts to be used with TeX. This file is part of the
% PSNFSS bundle, version 9"
% @}
%
% The idea is to have all the characters normally included in Type 1 fonts
% available for typesetting. This is effectively the characters in Adobe
% Standard encoding, ISO Latin 1, Windows ANSI including the euro symbol,
% MacRoman, and some extra characters from Lucida.
%
% Character code assignments were made as follows:
%
% (1) the Windows ANSI characters are almost all in their Windows ANSI
% positions, because some Windows users cannot easily reencode the
% fonts, and it makes no difference on other systems. The only Windows
% ANSI characters not available are those that make no sense for
% typesetting -- rubout (127 decimal), nobreakspace (160), softhyphen
% (173). quotesingle and grave are moved just because it's such an
% irritation not having them in TeX positions.
%
% (2) Remaining characters are assigned arbitrarily to the lower part
% of the range, avoiding 0, 10 and 13 in case we meet dumb software.
%
% (3) Y&Y Lucida Bright includes some extra text characters; in the
% hopes that other PostScript fonts, perhaps created for public
% consumption, will include them, they are included starting at 0x12.
% These are /dotlessj /ff /ffi /ffl.
%
% (4) hyphen appears twice for compatibility with both ASCII and Windows.
%
% (5) /Euro was assigned to 128, as in Windows ANSI
%
% (6) Missing characters from MacRoman encoding incorporated as follows:
%
% PostScript MacRoman TeXBase1
% -------------- -------------- --------------
% /notequal 173 0x16
% /infinity 176 0x17
% /lessequal 178 0x18
% /greaterequal 179 0x19
% /partialdiff 182 0x1A
% /summation 183 0x1B
% /product 184 0x1C
% /pi 185 0x1D
% /integral 186 0x81
% /Omega 189 0x8D
% /radical 195 0x8E
% /approxequal 197 0x8F
% /Delta 198 0x9D
% /lozenge 215 0x9E
%
/TeXBase1Encoding [
% 0x00
/.notdef /dotaccent /fi /fl
/fraction /hungarumlaut /Lslash /lslash
/ogonek /ring /.notdef /breve
/minus /.notdef /Zcaron /zcaron
% 0x10
/caron /dotlessi /dotlessj /ff
/ffi /ffl /notequal /infinity
/lessequal /greaterequal /partialdiff /summation
/product /pi /grave /quotesingle
% 0x20
/space /exclam /quotedbl /numbersign
/dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus
/comma /hyphen /period /slash
% 0x30
/zero /one /two /three
/four /five /six /seven
/eight /nine /colon /semicolon
/less /equal /greater /question
% 0x40
/at /A /B /C
/D /E /F /G
/H /I /J /K
/L /M /N /O
% 0x50
/P /Q /R /S
/T /U /V /W
/X /Y /Z /bracketleft
/backslash /bracketright /asciicircum /underscore
% 0x60
/quoteleft /a /b /c
/d /e /f /g
/h /i /j /k
/l /m /n /o
% 0x70
/p /q /r /s
/t /u /v /w
/x /y /z /braceleft
/bar /braceright /asciitilde /.notdef
% 0x80
/Euro /integral /quotesinglbase /florin
/quotedblbase /ellipsis /dagger /daggerdbl
/circumflex /perthousand /Scaron /guilsinglleft
/OE /Omega /radical /approxequal
% 0x90
/.notdef /.notdef /.notdef /quotedblleft
/quotedblright /bullet /endash /emdash
/tilde /trademark /scaron /guilsinglright
/oe /Delta /lozenge /Ydieresis
% 0xA0
/.notdef /exclamdown /cent /sterling
/currency /yen /brokenbar /section
/dieresis /copyright /ordfeminine /guillemotleft
/logicalnot /hyphen /registered /macron
% 0xB0
/degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /periodcentered
/cedilla /onesuperior /ordmasculine /guillemotright
/onequarter /onehalf /threequarters /questiondown
% 0xC0
/Agrave /Aacute /Acircumflex /Atilde
/Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis
/Igrave /Iacute /Icircumflex /Idieresis
% 0xD0
/Eth /Ntilde /Ograve /Oacute
/Ocircumflex /Otilde /Odieresis /multiply
/Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls
% 0xE0
/agrave /aacute /acircumflex /atilde
/adieresis /aring /ae /ccedilla
/egrave /eacute /ecircumflex /edieresis
/igrave /iacute /icircumflex /idieresis
% 0xF0
/eth /ntilde /ograve /oacute
/ocircumflex /otilde /odieresis /divide
/oslash /ugrave /uacute /ucircumflex
/udieresis /yacute /thorn /ydieresis
] def
%%EndProcSet
%%BeginProcSet: texps.pro 0 0
%!
TeXDict begin/rf{findfont dup length 1 add dict begin{1 index/FID ne 2
index/UniqueID ne and{def}{pop pop}ifelse}forall[1 index 0 6 -1 roll
exec 0 exch 5 -1 roll VResolution Resolution div mul neg 0 0]FontType 0
ne{/Metrics exch def dict begin Encoding{exch dup type/integertype ne{
pop pop 1 sub dup 0 le{pop}{[}ifelse}{FontMatrix 0 get div Metrics 0 get
div def}ifelse}forall Metrics/Metrics currentdict end def}{{1 index type
/nametype eq{exit}if exch pop}loop}ifelse[2 index currentdict end
definefont 3 -1 roll makefont/setfont cvx]cvx def}def/ObliqueSlant{dup
sin S cos div neg}B/SlantFont{4 index mul add}def/ExtendFont{3 -1 roll
mul exch}def/ReEncodeFont{CharStrings rcheck{/Encoding false def dup[
exch{dup CharStrings exch known not{pop/.notdef/Encoding true def}if}
forall Encoding{]exch pop}{cleartomark}ifelse}if/Encoding exch def}def
end
%%EndProcSet
%%BeginFont: CMSY5
%!PS-AdobeFont-1.1: CMSY5 1.0
%%CreationDate: 1991 Aug 15 07:21:16
% Copyright (C) 1997 American Mathematical Society. All Rights Reserved.
11 dict begin
/FontInfo 7 dict dup begin
/version (1.0) readonly def
/Notice (Copyright (C) 1997 American Mathematical Society. All Rights Reserved) readonly def
/FullName (CMSY5) readonly def
/FamilyName (Computer Modern) readonly def
/Weight (Medium) readonly def
/ItalicAngle -14.035 def
/isFixedPitch false def
end readonly def
/FontName /CMSY5 def
/PaintType 0 def
/FontType 1 def
/FontMatrix [0.001 0 0 0.001 0 0] readonly def
/Encoding 256 array
0 1 255 {1 index exch /.notdef put} for
dup 99 /floorright put
dup 100 /ceilingleft put
readonly def
/FontBBox{21 -944 1448 791}readonly def
currentdict end
currentfile eexec
D9D66F633B846A97B686A97E45A3D0AA052F09F9C8ADE9D907C058B87E9B6964
7D53359E51216774A4EAA1E2B58EC3176BD1184A633B951372B4198D4E8C5EF4
A213ACB58AA0A658908035BF2ED8531779838A960DFE2B27EA49C37156989C85
E21B3ABF72E39A89232CD9F4237FC80C9E64E8425AA3BEF7DED60B122A52922A
221A37D9A807DD01161779DDE7D5FC1B2109839E5B52DFBAF552B11EFFB6A16C
F03FB920C15AE724EFDF0CCBF00A838D34440FF9FED532F44036AD22561184C5
283722DDFA7285E62754372D716D704AC0E00B2F6AB67154241C7449AA047833
94CEDB08E8C92907FE72A0B05AE36A7B9226ACD6E7890A0B528FDDE84A950FC6
801DE75CF2E739E9121149CCB8B1C87A106822648D84A3D3FBF295EE6C4BF403
BBE9A1C1F6DAEDD1E642ACC486E609703D7612BFFD10C324F5DC710811F7F614
3691B400E3773987424C0D2B0D8A736873C6371DDB2442F05E018A2B5CA9A4AA
17AABB95D09E5890CFFFED5AC01495D89A53D3C9AD5A9C23D5050E53AD0EDBCB
74CFD3E2297008B9B01947831838A5B7BF29DF7D79A3F534A81ACBE9E424B488
9787119A37A367694753F76DB105736707A84BB23F4C3DAE1E0B78A3CC6A1106
C7773513D26BBC0F5430E65C267E5E6DE15CD7892809F70EA60A2E408BD51350
B50F4A68C7BCF87675D469BDE3B7659B333C16A75AACA615D5167C62645525A6
BFF13F92A1451C13650B0D2B0436242F29EDE4208039ED6C5CFEA7EFE27D553D
5A159E4F81F07C531EFB5276A46B78840437598568CD948FA43DD678B024DCF6
BEA8B9591B57D126861A0C94FDA0E007D08FD7D9C1EB19900E106C1CC23190F7
C2805A6772AEB2ACC12238F965C54541E05622BED8879846246919CFFED562B5
74FB409A25F97FAA02A98AB3289D40779FA7CBE47F35F6829741CDBDAC0D8230
C49DD2E702B2660E99871FD026B30697530DCE
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
cleartomark
%%EndFont
%%BeginFont: CMSY10
%!PS-AdobeFont-1.1: CMSY10 1.0
%%CreationDate: 1991 Aug 15 07:20:57
% Copyright (C) 1997 American Mathematical Society. All Rights Reserved.
11 dict begin
/FontInfo 7 dict dup begin
/version (1.0) readonly def
/Notice (Copyright (C) 1997 American Mathematical Society. All Rights Reserved) readonly def
/FullName (CMSY10) readonly def
/FamilyName (Computer Modern) readonly def
/Weight (Medium) readonly def
/ItalicAngle -14.035 def
/isFixedPitch false def
end readonly def
/FontName /CMSY10 def
/PaintType 0 def
/FontType 1 def
/FontMatrix [0.001 0 0 0.001 0 0] readonly def
/Encoding 256 array
0 1 255 {1 index exch /.notdef put} for
dup 13 /circlecopyrt put
dup 15 /bullet put
readonly def
/FontBBox{-29 -960 1116 775}readonly def
currentdict end
currentfile eexec
D9D66F633B846A97B686A97E45A3D0AA052F09F9C8ADE9D907C058B87E9B6964
7D53359E51216774A4EAA1E2B58EC3176BD1184A633B951372B4198D4E8C5EF4
A213ACB58AA0A658908035BF2ED8531779838A960DFE2B27EA49C37156989C85
E21B3ABF72E39A89232CD9F4237FC80C9E64E8425AA3BEF7DED60B122A52922A
221A37D9A807DD01161779DDE7D31FF2B87F97C73D63EECDDA4C49501773468A
27D1663E0B62F461F6E40A5D6676D1D12B51E641C1D4E8E2771864FC104F8CBF
5B78EC1D88228725F1C453A678F58A7E1B7BD7CA700717D288EB8DA1F57C4F09
0ABF1D42C5DDD0C384C7E22F8F8047BE1D4C1CC8E33368FB1AC82B4E96146730
DE3302B2E6B819CB6AE455B1AF3187FFE8071AA57EF8A6616B9CB7941D44EC7A
71A7BB3DF755178D7D2E4BB69859EFA4BBC30BD6BB1531133FD4D9438FF99F09
4ECC068A324D75B5F696B8688EEB2F17E5ED34CCD6D047A4E3806D000C199D7C
515DB70A8D4F6146FE068DC1E5DE8BC57036431151EC603C8BCFE359BBD953AD
5F3D998D8365AF76D4CF6A06FB66E1CBCFDB3A67D8880377CD677B9705EE853A
D849F88A828E244FA5816B7D081D4D1975A56D771790C21AE05809BEE6613452
953F26C39CE61F0E134BC35404FE2F0B7D244D9A6F66E4D817D1C65024013AD3
5F242EDE94633B8E20EA42B07F83BA649F12B784B2AAFA542BC597C6C2C9AE9C
39D60FBA6CD16AADB5DFDABF22F37E244DF3987FBFA55031CFCD46ADF03650CE
D6CDFFD87BF7407FFB63F3FE4C29FE753896101B2CEAB9007B66E29D6A5B85D3
FF91F888E445677157A5996FC7A3BD19BAF3A3BCF33F0719B992A0F013B1F0A1
82E42DF6F651071FB407F448DFF37653E2A0569BDD8EABC3280B3582745DB98B
644E5B341F531B0D81ED85F815B993C2B8B34CDDC6AE97606F6B3B1C5427F174
362FAB82B935087B568E6F526347058C406E878F1CC2DD05C26D35565347C5A5
7575891BB4
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
cleartomark
%%EndFont
TeXDict begin 40258431 52099146 1000 600 600 (paper-letter/ref.dvi)
@start /Fa 134[72 72 72 1[72 72 72 72 1[72 72 72 72 72
72 1[72 72 72 72 72 72 72 72 72 97[{TeXBase1Encoding ReEncodeFont}22
119.552 /Courier rf /Fb 130[40 1[40 1[40 40 1[40 40 40
40 40 1[40 40 40 40 40 40 1[40 40 1[40 40 40 40 40 40
1[40 1[40 1[40 30[40 10[40 40 40 1[40 40 40 40 40 40
2[40 37[{TeXBase1Encoding ReEncodeFont}37 66.4176 /Courier
rf /Fc 162[40 1[40 91[{TeXBase1Encoding ReEncodeFont}2
119.552 /Times-Roman rf /Fd 134[29 1[42 2[16 29 19 1[32
32 32 1[13 3[32 32 1[32 32 29 40[16 10[16 16 46[{
TeXBase1Encoding ReEncodeFont}17 58.1154 /Helvetica rf
/Fe 140[26 9[18 105[{TeXBase1Encoding ReEncodeFont}2
66.4176 /Times-Italic rf /Ff 202[25 25 25 25 25 49[{
TeXBase1Encoding ReEncodeFont}5 49.8132 /Times-Roman
rf /Fg 202[29 29 29 29 29 49[{TeXBase1Encoding ReEncodeFont}5
58.1154 /Times-Roman rf /Fh 133[50 1[50 50 50 50 50 50
50 50 50 50 50 50 50 2[50 50 50 50 50 50 50 50 50 1[50
52[50 42[{TeXBase1Encoding ReEncodeFont}25 83.022 /Courier-Bold
rf /Fi 103[45 15[45 10[45 45 45 45 45 45 45 45 45 45
45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45
45 45 45 1[45 45 45 45 45 45 45 45 45 45 45 45 45 45
45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45
45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45
45 45 45 45 45 45 45 45 45 45 45 33[{TeXBase1Encoding ReEncodeFont}94
74.7198 /Courier rf /Fj 155[28 28 99[{}2 41.511 /CMSY5
rf /Fk 133[50 50 50 72 50 55 28 50 33 55 55 55 55 83
22 50 22 22 55 55 28 55 55 50 55 55 7[66 66 94 1[72 61
66 72 1[66 1[72 83 55 66 1[28 1[78 61 66 72 72 66 66
7[55 55 55 55 55 55 55 55 55 55 1[28 4[33 33 37[50 2[{
TeXBase1Encoding ReEncodeFont}60 99.6264 /Helvetica rf
/Fl 107[29 29 24[29 33 33 48 33 33 18 26 22 33 33 33
33 52 18 33 18 18 33 33 22 29 33 29 33 29 22 7[48 63
1[48 41 37 2[37 48 48 4[22 48 1[37 41 1[44 1[48 6[18
33 1[33 33 33 33 33 33 33 33 1[17 22 17 2[22 22 22 1[55
33[37 37 2[{TeXBase1Encoding ReEncodeFont}62 66.4176
/Times-Roman rf /Fm 134[60 60 86 60 66 33 60 40 1[66
66 66 100 27 60 27 27 66 66 33 66 66 60 66 66 6[73 80
80 113 80 86 73 80 86 93 80 93 86 100 66 80 60 33 86
93 73 80 86 86 80 80 7[66 66 66 66 66 66 66 66 66 66
1[33 40 33 41[60 2[{TeXBase1Encoding ReEncodeFont}64
119.552 /Helvetica rf /Fn 167[80 113 80 86 73 80 86 2[93
86 4[33 86 93 73 80 3[86 65[{TeXBase1Encoding ReEncodeFont}15
119.552 /Helvetica-Bold rf /Fo 103[50 15[50 10[50 50
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 1[50 50 50 50 1[50 50
50 50 50 50 50 50 1[50 50 50 50 50 50 50 50 50 50 50
50 50 50 50 50 1[50 50 50 50 50 50 50 50 50 50 50 50
50 50 50 50 50 50 50 50 50 50 50 50 50 50 1[50 50 50
33[{TeXBase1Encoding ReEncodeFont}90 83.022 /Courier
rf /Fp 134[42 42 60 42 46 23 42 28 1[46 46 46 69 18 42
1[18 46 46 23 46 46 42 46 46 8[55 2[60 51 55 60 1[55
65 60 69 46 2[23 60 1[51 55 60 60 1[55 7[46 46 46 46
46 46 46 46 46 46 1[23 28 42[42 2[{TeXBase1Encoding ReEncodeFont}53
83.022 /Helvetica rf /Fq 107[46 25[32 37 37 55 37 42
23 32 32 42 42 42 42 60 23 37 23 23 42 42 23 37 42 37
42 42 12[46 42 51 1[51 60 55 69 46 2[28 1[60 51 51 1[55
1[51 15[42 1[23 21 28 21 41[42 2[{TeXBase1Encoding ReEncodeFont}47
83.022 /Times-Italic rf /Fr 105[42 27[37 42 42 60 42
46 28 32 37 46 46 42 46 69 23 46 28 23 46 42 28 37 46
37 46 42 7[60 1[83 60 60 55 46 60 1[51 65 60 78 55 2[32
65 65 51 55 60 60 55 60 1[42 4[28 42 42 42 42 42 42 42
42 42 42 1[21 28 5[28 36[46 2[{TeXBase1Encoding ReEncodeFont}64
83.022 /Times-Bold rf /Fs 240[42 1[83 13[{}2 83.022 /CMSY10
rf /Ft 104[83 42 1[37 37 24[37 42 42 60 42 42 23 32 28
42 42 42 42 65 23 42 23 23 42 42 28 37 42 37 42 37 28
2[28 1[28 51 60 60 78 60 60 51 46 55 60 46 60 60 74 51
60 32 28 60 60 46 51 60 55 55 60 1[37 1[47 1[23 23 42
42 42 42 42 42 42 42 42 42 23 21 28 21 47 1[28 28 28
1[69 3[28 29[46 46 2[{TeXBase1Encoding ReEncodeFont}85
83.022 /Times-Roman rf /Fu 133[37 37 37 54 37 42 21 37
25 1[42 42 42 62 17 37 17 17 42 42 21 42 42 37 42 42
12[46 6[62 12[76 5[21 42 42 42 1[42 1[42 42 42 42 21
21 25 45[{TeXBase1Encoding ReEncodeFont}40 74.7198 /Helvetica
rf /Fv 134[50 1[72 1[55 33 1[44 2[50 55 4[28 55 1[33
44 55 2[50 13[55 2[61 9[61 70[{TeXBase1Encoding ReEncodeFont}16
99.6264 /Times-Bold rf /Fw 139[28 1[33 4[78 28 2[28 50
2[44 1[44 50 44 27[61 72 9[28 50 50 5[50 50 50 3[25 44[{
TeXBase1Encoding ReEncodeFont}19 99.6264 /Times-Roman
rf /Fx 137[72 80 40 72 48 2[80 80 120 1[72 1[32 3[80
80 2[80 14[104 5[80 1[72 2[112 88 1[104 21[40 1[40 44[{
TeXBase1Encoding ReEncodeFont}21 143.462 /Helvetica rf
/Fy 140[72 6[32 6[80 3[80 14[104 28[80 1[80 80 3[40 46[{
TeXBase1Encoding ReEncodeFont}9 143.462 /Helvetica-Oblique
rf /Fz 134[103 103 1[103 115 57 103 69 1[115 115 115
172 46 2[46 115 1[57 115 115 103 1[115 8[138 3[126 138
149 1[138 161 149 172 115 2[57 149 2[138 149 149 21[69
45[{TeXBase1Encoding ReEncodeFont}34 206.559 /Helvetica
rf end
%%EndProlog
%%BeginSetup
%%Feature: *Resolution 600dpi
TeXDict begin
%%BeginPaperSize: Letter
/setpagedevice where
{ pop << /PageSize [612 792] >> setpagedevice }
{ /letter where { pop letter } if }
ifelse
%%EndPaperSize
end
%%EndSetup
%%Page: 1 1
TeXDict begin 1 0 bop 0 83 3901 9 v 1520 446 a Fz(Python)58
b(Ref)-6 b(erence)57 b(Man)n(ual)3015 676 y Fy(Release)38
b(2.5.3)2684 1852 y Fx(Guido)g(v)l(an)i(Rossum)2365 2035
y(F)-6 b(red)39 b(L.)g(Dr)o(ak)m(e)n(,)f(Jr)-7 b(.,)39
b(editor)3044 4091 y Fw(19th)24 b(December)l(,)h(2008)2676
5201 y Fv(Python)g(Softwar)n(e)h(F)n(oundation)3019 5317
y Fw(Email:)k Fu(docs@p)n(ython.org)p eop end
%%Page: 2 2
TeXDict begin 2 1 bop 0 83 a Ft(Cop)o(yright)380 80 y(c)357
83 y Fs(\015)20 b Ft(2001-2008)d(Python)i(Softw)o(are)h(F)o(oundation.)
i(All)f(rights)f(reserv)o(ed.)0 230 y(Cop)o(yright)380
227 y(c)357 230 y Fs(\015)g Ft(2000)f(BeOpen.com.)24
b(All)c(rights)g(reserv)o(ed.)0 377 y(Cop)o(yright)380
374 y(c)357 377 y Fs(\015)g Ft(1995-2000)d(Corporation)h(for)h
(National)h(Research)g(Initiati)n(v)o(es.)k(All)d(rights)f(reserv)o
(ed.)0 524 y(Cop)o(yright)380 521 y(c)357 524 y Fs(\015)g
Ft(1991-1995)d(Stichting)j(Mathematisch)f(Centrum.)24
b(All)d(rights)f(reserv)o(ed.)0 671 y(See)h(the)f(end)f(of)h(this)h
(document)d(for)i(complete)f(license)h(and)g(permissions)f
(information.)p eop end
%%Page: 1 3
TeXDict begin 1 2 bop 1796 2111 a Fr(Abstract)0 2341
y Ft(Python)25 b(is)j(an)e(interpreted,)g(object-oriented,)f(high-le)n
(v)o(el)f(programming)f(language)i(with)h(dynamic)f(semantics.)44
b(Its)27 b(high-le)n(v)o(el)0 2441 y(b)n(uilt)19 b(in)h(data)f
(structures,)g(combined)e(with)i(dynamic)f(typing)g(and)h(dynamic)f
(binding,)f(mak)o(e)i(it)h(v)o(ery)e(attracti)n(v)o(e)g(for)h(rapid)g
(applica-)0 2540 y(tion)g(de)n(v)o(elopment,)d(as)k(well)g(as)g(for)f
(use)g(as)h(a)g(scripting)e(or)h(glue)g(language)f(to)h(connect)f(e)o
(xisting)h(components)e(together)-5 b(.)23 b(Python')-5
b(s)0 2640 y(simple,)25 b(easy)g(to)g(learn)f(syntax)f(emphasizes)h
(readability)f(and)h(therefore)f(reduces)h(the)g(cost)h(of)f(program)f
(maintenance.)36 b(Python)0 2739 y(supports)24 b(modules)f(and)h
(packages,)h(which)f(encourages)e(program)h(modularity)f(and)i(code)g
(reuse.)38 b(The)25 b(Python)e(interpreter)g(and)0 2839
y(the)c(e)o(xtensi)n(v)o(e)e(standard)h(library)f(are)i(a)n(v)n
(ailable)f(in)h(source)f(or)g(binary)g(form)f(without)h(char)o(ge)f
(for)h(all)i(major)d(platforms,)h(and)g(can)h(be)0 2939
y(freely)g(distrib)n(uted.)0 3086 y(This)j(reference)e(manual)g
(describes)i(the)f(syntax)g(and)g(\223core)g(semantics\224)h(of)f(the)h
(language.)28 b(It)22 b(is)g(terse,)g(b)n(ut)g(attempts)g(to)f(be)h(e)o
(xact)0 3185 y(and)30 b(complete.)55 b(The)31 b(semantics)f(of)h
(non-essential)e(b)n(uilt-in)h(object)g(types)h(and)f(of)g(the)h(b)n
(uilt-in)f(functions)f(and)h(modules)g(are)0 3285 y(described)19
b(in)h(the)g Fq(Python)f(Libr)o(ary)i(Refer)m(ence)p
Ft(.)j(F)o(or)c(an)g(informal)f(introduction)e(to)j(the)h(language,)d
(see)j(the)f Fq(Python)f(T)-5 b(utorial)p Ft(.)25 b(F)o(or)0
3384 y(C)20 b(or)f(C)219 3377 y(++)333 3384 y(programmers,)e(tw)o(o)i
(additional)f(manuals)h(e)o(xist:)25 b Fq(Extending)18
b(and)g(Embedding)f(the)i(Python)g(Interpr)m(eter)g Ft(describes)g(the)
0 3484 y(high-le)n(v)o(el)g(picture)h(of)h(ho)n(w)g(to)g(write)h(a)f
(Python)f(e)o(xtension)g(module,)g(and)h(the)g Fq(Python/C)f(API)h
(Refer)m(ence)g(Manual)f Ft(describes)h(the)0 3584 y(interf)o(aces)f(a)
n(v)n(ailable)f(to)i(C/C)878 3577 y(++)993 3584 y(programmers)c(in)k
(detail.)p eop end
%%Page: 2 4
TeXDict begin 2 3 bop eop end
%%Page: 1 5
TeXDict begin 1 4 bop 2764 747 a Fz(CONTENTS)0 1594 y
Fr(1)83 b(Intr)o(oduction)3281 b(1)125 1694 y Ft(1.1)110
b(Alternate)20 b(Implementations)35 b(.)41 b(.)h(.)f(.)g(.)g(.)h(.)f(.)
g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h
(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)143
b(1)125 1793 y(1.2)110 b(Notation)74 b(.)41 b(.)g(.)g(.)h(.)f(.)g(.)h
(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f
(.)g(.)g(.)h(.)f(.)g(.)g(.)143 b(2)0 1976 y Fr(2)83 b(Lexical)20
b(analysis)3172 b(3)125 2076 y Ft(2.1)110 b(Line)20 b(structure)25
b(.)41 b(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)
h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g
(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)143
b(3)125 2175 y(2.2)110 b(Other)20 b(tok)o(ens)63 b(.)41
b(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f
(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)
h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)143 b(6)125
2275 y(2.3)110 b(Identi\002ers)20 b(and)f(k)o(e)o(yw)o(ords)44
b(.)d(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g
(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)
g(.)g(.)h(.)f(.)g(.)g(.)143 b(6)125 2374 y(2.4)110 b(Literals)49
b(.)42 b(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)
f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g
(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)143
b(7)125 2474 y(2.5)110 b(Operators)37 b(.)k(.)g(.)g(.)h(.)f(.)g(.)h(.)f
(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)
h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g
(.)g(.)h(.)f(.)g(.)g(.)102 b(11)125 2574 y(2.6)110 b(Delimiters)77
b(.)41 b(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)
g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f
(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102
b(11)0 2756 y Fr(3)83 b(Data)19 b(model)3284 b(13)125
2856 y Ft(3.1)110 b(Objects,)21 b(v)n(alues)e(and)h(types)h(.)41
b(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h
(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
g(.)h(.)f(.)g(.)g(.)102 b(13)125 2956 y(3.2)110 b(The)20
b(standard)f(type)h(hierarchy)56 b(.)42 b(.)f(.)g(.)g(.)h(.)f(.)g(.)g
(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)
g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102
b(14)125 3055 y(3.3)110 b(Ne)n(w-style)20 b(and)g(classic)h(classes)78
b(.)41 b(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)
g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h
(.)f(.)g(.)g(.)102 b(21)125 3155 y(3.4)110 b(Special)21
b(method)d(names)54 b(.)41 b(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)
h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g
(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102
b(21)0 3337 y Fr(4)83 b(Execution)19 b(model)3100 b(35)125
3437 y Ft(4.1)110 b(Naming)20 b(and)f(binding)54 b(.)42
b(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g
(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)
f(.)g(.)g(.)h(.)f(.)g(.)g(.)102 b(35)125 3537 y(4.2)110
b(Exceptions)57 b(.)41 b(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)
g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f
(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)
102 b(36)0 3719 y Fr(5)83 b(Expr)o(essions)3269 b(39)125
3819 y Ft(5.1)110 b(Arithmetic)20 b(con)m(v)o(ersions)26
b(.)41 b(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)
g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h
(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102 b(39)125 3919 y(5.2)110
b(Atoms)81 b(.)42 b(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g
(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)
f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g
(.)102 b(39)125 4018 y(5.3)110 b(Primaries)47 b(.)41
b(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g
(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)
g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102
b(43)125 4118 y(5.4)110 b(The)20 b(po)n(wer)f(operator)j(.)41
b(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f
(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)
h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102 b(46)125 4218 y(5.5)110
b(Unary)20 b(arithmetic)f(operations)54 b(.)42 b(.)f(.)g(.)g(.)h(.)f(.)
g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h
(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102
b(47)125 4317 y(5.6)110 b(Binary)20 b(arithmetic)g(operations)35
b(.)42 b(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)
f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g
(.)h(.)f(.)g(.)g(.)102 b(47)125 4417 y(5.7)110 b(Shifting)20
b(operations)40 b(.)h(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g
(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)
g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102
b(48)125 4516 y(5.8)110 b(Binary)20 b(bit-wise)g(operations)43
b(.)e(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h
(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
g(.)h(.)f(.)g(.)g(.)102 b(48)125 4616 y(5.9)110 b(Comparisons)50
b(.)41 b(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)
h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g
(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102
b(49)125 4716 y(5.10)68 b(Boolean)20 b(operations)31
b(.)41 b(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)
h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f
(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102 b(50)125 4815
y(5.11)68 b(Lambdas)60 b(.)41 b(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h
(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)
g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f
(.)g(.)g(.)102 b(50)125 4915 y(5.12)68 b(Expression)19
b(lists)29 b(.)42 b(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g
(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)
f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102
b(51)125 5015 y(5.13)68 b(Ev)n(aluation)19 b(order)59
b(.)41 b(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)
g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h
(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102 b(51)125
5114 y(5.14)68 b(Summary)41 b(.)g(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g
(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)
g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h
(.)f(.)g(.)g(.)102 b(51)0 5297 y Fr(6)83 b(Simple)21
b(statements)3048 b(53)125 5396 y Ft(6.1)110 b(Expression)19
b(statements)61 b(.)41 b(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)
f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g
(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102 b(53)p
0 5549 3901 4 v 3882 5649 a Fp(i)p eop end
%%Page: 2 6
TeXDict begin 2 5 bop 125 83 a Ft(6.2)110 b(Assert)21
b(statements)93 b(.)41 b(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)
g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f
(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102
b(53)125 183 y(6.3)110 b(Assignment)20 b(statements)95
b(.)41 b(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f
(.)g(.)g(.)h(.)f(.)g(.)g(.)102 b(54)125 282 y(6.4)110
b(The)20 b Fo(pass)g Ft(statement)50 b(.)42 b(.)f(.)g(.)g(.)h(.)f(.)g
(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)
f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g
(.)102 b(56)125 382 y(6.5)110 b(The)20 b Fo(del)g Ft(statement)100
b(.)42 b(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)
f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g
(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102 b(56)125 482 y(6.6)110
b(The)20 b Fo(print)g Ft(statement)63 b(.)41 b(.)g(.)g(.)h(.)f(.)g(.)g
(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)
g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102
b(57)125 581 y(6.7)110 b(The)20 b Fo(return)g Ft(statement)75
b(.)41 b(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f
(.)g(.)g(.)h(.)f(.)g(.)g(.)102 b(57)125 681 y(6.8)110
b(The)20 b Fo(yield)g Ft(statement)63 b(.)41 b(.)g(.)g(.)h(.)f(.)g(.)g
(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)
g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102
b(57)125 780 y(6.9)110 b(The)20 b Fo(raise)g Ft(statement)63
b(.)41 b(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)
g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h
(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102 b(58)125 880 y(6.10)68
b(The)20 b Fo(break)g Ft(statement)63 b(.)41 b(.)g(.)g(.)h(.)f(.)g(.)g
(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)
g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102
b(59)125 980 y(6.11)68 b(The)20 b Fo(continue)g Ft(statement)99
b(.)42 b(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)
f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g
(.)h(.)f(.)g(.)g(.)102 b(59)125 1079 y(6.12)68 b(The)20
b Fo(import)g Ft(statement)75 b(.)41 b(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g
(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)
f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102
b(59)125 1179 y(6.13)68 b(The)20 b Fo(global)g Ft(statement)75
b(.)41 b(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)
g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f
(.)g(.)g(.)h(.)f(.)g(.)g(.)102 b(61)125 1279 y(6.14)68
b(The)20 b Fo(exec)g Ft(statement)50 b(.)42 b(.)f(.)g(.)g(.)h(.)f(.)g
(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)
f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g
(.)102 b(62)0 1461 y Fr(7)83 b(Compound)20 b(statements)2896
b(63)125 1561 y Ft(7.1)110 b(The)20 b Fo(if)h Ft(statement)k(.)41
b(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h
(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)
g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102 b(64)125 1660
y(7.2)110 b(The)20 b Fo(while)g Ft(statement)63 b(.)41
b(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g
(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)
g(.)g(.)h(.)f(.)g(.)g(.)102 b(64)125 1760 y(7.3)110 b(The)20
b Fo(for)g Ft(statement)38 b(.)j(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)
f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g
(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102
b(64)125 1860 y(7.4)110 b(The)20 b Fo(try)g Ft(statement)38
b(.)j(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h
(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)
g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102 b(65)125 1959
y(7.5)110 b(The)20 b Fo(with)g Ft(statement)50 b(.)42
b(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g
(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)
f(.)g(.)g(.)h(.)f(.)g(.)g(.)102 b(66)125 2059 y(7.6)110
b(Function)19 b(de\002nitions)71 b(.)42 b(.)f(.)g(.)g(.)h(.)f(.)g(.)g
(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)
g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102
b(67)125 2159 y(7.7)110 b(Class)22 b(de\002nitions)62
b(.)41 b(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)
g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h
(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102 b(68)0
2341 y Fr(8)83 b(T)-8 b(op-le)o(v)o(el)20 b(components)2924
b(69)125 2441 y Ft(8.1)110 b(Complete)20 b(Python)f(programs)72
b(.)42 b(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)
f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g
(.)h(.)f(.)g(.)g(.)102 b(69)125 2540 y(8.2)110 b(File)21
b(input)44 b(.)d(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)
h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g
(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102
b(69)125 2640 y(8.3)110 b(Interacti)n(v)o(e)19 b(input)70
b(.)41 b(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)
g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h
(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102 b(69)125
2740 y(8.4)110 b(Expression)19 b(input)53 b(.)41 b(.)g(.)h(.)f(.)g(.)g
(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)
g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h
(.)f(.)g(.)g(.)102 b(70)0 2922 y Fr(A)65 b(History)19
b(and)h(License)2983 b(71)125 3022 y Ft(A.1)92 b(History)20
b(of)g(the)g(softw)o(are)34 b(.)41 b(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)
g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h
(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)102
b(71)125 3122 y(A.2)92 b(T)-6 b(erms)20 b(and)g(conditions)f(for)g
(accessing)h(or)g(otherwise)g(using)f(Python)47 b(.)41
b(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f
(.)g(.)g(.)102 b(72)125 3221 y(A.3)92 b(Licenses)21 b(and)e(Ackno)n
(wledgements)e(for)j(Incorporated)d(Softw)o(are)54 b(.)41
b(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h
(.)f(.)g(.)g(.)102 b(75)0 3404 y Fr(Index)3614 b(85)p
0 5549 3901 4 v 0 5649 a Fp(ii)p eop end
%%Page: 1 7
TeXDict begin 1 6 bop 0 83 3901 9 v 3503 230 a Fp(CHAPTER)3641
427 y Fn(ONE)p 0 515 V 2821 978 a Fz(Introduction)0 1457
y Ft(This)20 b(reference)f(manual)g(describes)h(the)g(Python)f
(programming)e(language.)23 b(It)d(is)i(not)d(intended)g(as)i(a)g
(tutorial.)0 1604 y(While)i(I)f(am)g(trying)f(to)i(be)f(as)h(precise)f
(as)h(possible,)f(I)g(chose)g(to)h(use)f(English)g(rather)f(than)h
(formal)f(speci\002cations)h(for)f(e)n(v)o(erything)0
1703 y(e)o(xcept)16 b(syntax)h(and)f(le)o(xical)h(analysis.)24
b(This)18 b(should)e(mak)o(e)h(the)g(document)e(more)h(understandable)f
(to)i(the)g(a)n(v)o(erage)f(reader)m(,)h(b)n(ut)g(will)0
1803 y(lea)n(v)o(e)j(room)f(for)g(ambiguities.)24 b(Consequently)-5
b(,)18 b(if)j(you)e(were)h(coming)f(from)g(Mars)h(and)g(tried)g(to)g
(re-implement)e(Python)h(from)g(this)0 1902 y(document)d(alone,)i(you)g
(might)g(ha)n(v)o(e)g(to)g(guess)h(things)f(and)g(in)h(f)o(act)f(you)g
(w)o(ould)g(probably)e(end)i(up)g(implementing)e(quite)i(a)h(dif)n
(ferent)0 2002 y(language.)25 b(On)c(the)g(other)f(hand,)g(if)h(you)f
(are)h(using)f(Python)g(and)g(w)o(onder)g(what)g(the)h(precise)g(rules)
g(about)e(a)j(particular)d(area)i(of)g(the)0 2102 y(language)e(are,)i
(you)f(should)g(de\002nitely)g(be)h(able)g(to)g(\002nd)g(them)f(here.)
27 b(If)21 b(you)f(w)o(ould)g(lik)o(e)h(to)g(see)h(a)f(more)f(formal)g
(de\002nition)g(of)h(the)0 2201 y(language,)d(maybe)h(you)h(could)f(v)n
(olunteer)f(your)h(time)i(\227)g(or)e(in)m(v)o(ent)g(a)i(cloning)e
(machine)g(:-\).)0 2348 y(It)i(is)g(dangerous)d(to)i(add)g(too)g(man)o
(y)f(implementation)f(details)j(to)f(a)h(language)e(reference)f
(document)h(\227)i(the)f(implementation)e(may)0 2448
y(change,)k(and)g(other)g(implementations)e(of)j(the)f(same)h(language)
e(may)h(w)o(ork)g(dif)n(ferently)-5 b(.)30 b(On)23 b(the)g(other)f
(hand,)g(there)g(is)h(currently)0 2547 y(only)15 b(one)h(Python)f
(implementation)g(in)h(widespread)f(use)h(\(although)f(alternate)g
(implementations)g(e)o(xist\),)h(and)g(its)h(particular)e(quirks)0
2647 y(are)h(sometimes)g(w)o(orth)g(being)f(mentioned,)g(especially)g
(where)h(the)g(implementation)e(imposes)i(additional)f(limitations.)23
b(Therefore,)0 2747 y(you')o(ll)c(\002nd)h(short)g(\223implementation)e
(notes\224)i(sprinkled)e(throughout)g(the)i(te)o(xt.)0
2894 y(Ev)o(ery)d(Python)g(implementation)f(comes)h(with)i(a)f(number)f
(of)h(b)n(uilt-in)f(and)h(standard)f(modules.)23 b(These)18
b(are)g(not)g(documented)d(here,)0 2993 y(b)n(ut)k(in)h(the)f(separate)
g Fq(Python)f(Libr)o(ary)h(Refer)m(ence)g Ft(document.)j(A)e(fe)n(w)f
(b)n(uilt-in)g(modules)f(are)h(mentioned)f(when)g(the)o(y)h(interact)g
(in)g(a)0 3093 y(signi\002cant)h(w)o(ay)g(with)g(the)h(language)d
(de\002nition.)0 3420 y Fm(1.1)121 b(Alter)s(nate)34
b(Implementations)0 3653 y Ft(Though)15 b(there)h(is)i(one)e(Python)f
(implementation)g(which)h(is)i(by)e(f)o(ar)h(the)g(most)g(popular)m(,)e
(there)h(are)h(some)f(alternate)h(implementations)0 3753
y(which)j(are)g(of)g(particular)f(interest)h(to)g(dif)n(ferent)f
(audiences.)0 3900 y(Kno)n(wn)g(implementations)f(include:)-125
4129 y(CPython)41 b(This)19 b(is)i(the)e(original)g(and)g
(most-maintained)e(implementation)g(of)j(Python,)e(written)h(in)h(C.)g
(Ne)n(w)g(language)e(features)h(gener)n(-)208 4229 y(ally)h(appear)f
(here)g(\002rst.)-55 4395 y(Jython)40 b(Python)25 b(implemented)f(in)j
(Ja)n(v)n(a.)43 b(This)27 b(implementation)d(can)i(be)h(used)f(as)h(a)f
(scripting)g(language)f(for)g(Ja)n(v)n(a)i(applications,)208
4495 y(or)c(can)g(be)h(used)f(to)h(create)g(applications)e(using)h(the)
h(Ja)n(v)n(a)g(class)g(libraries.)35 b(It)24 b(is)h(also)f(often)f
(used)g(to)h(create)f(tests)i(for)e(Ja)n(v)n(a)208 4594
y(libraries.)h(More)c(information)d(can)j(be)h(found)d(at)j(the)f
(Jython)f(website.)-390 4760 y(Python)g(for)h(.NET)41
b(This)21 b(implementation)e(actually)i(uses)g(the)h(CPython)e
(implementation,)f(b)n(ut)i(is)h(a)g(managed)d(.NET)i(application)f
(and)h(mak)o(es)208 4860 y(.NET)16 b(libraries)h(a)n(v)n(ailable.)24
b(This)17 b(w)o(as)h(created)f(by)f(Brian)i(Llo)o(yd.)23
b(F)o(or)16 b(more)h(information,)e(see)j(the)f(Python)f(for)h(.NET)g
(home)208 4960 y(page.)-208 5126 y(IronPython)39 b(An)20
b(alternate)f(Python)g(for)g(.NET)-6 b(.)20 b(Unlik)o(e)f(Python.NET)-6
b(,)18 b(this)j(is)g(a)f(complete)f(Python)g(implementation)f(that)i
(generates)f(IL,)208 5225 y(and)j(compiles)g(Python)g(code)g(directly)g
(to)h(.NET)f(assemblies.)33 b(It)23 b(w)o(as)h(created)e(by)g(Jim)h
(Hugunin,)f(the)g(original)g(creator)g(of)208 5325 y(Jython.)h(F)o(or)d
(more)g(information,)d(see)k(the)f(IronPython)e(website.)p
0 5549 3901 4 v 3854 5649 a Fp(1)p eop end
%%Page: 2 8
TeXDict begin 2 7 bop -9 83 a Ft(PyPy)41 b(An)28 b(implementation)f(of)
h(Python)f(written)i(in)f(Python;)k(e)n(v)o(en)c(the)g(bytecode)f
(interpreter)g(is)j(written)e(in)h(Python.)49 b(This)29
b(is)208 183 y(e)o(x)o(ecuted)23 b(using)i(CPython)g(as)h(the)f
(underlying)e(interpreter)-5 b(.)39 b(One)25 b(of)g(the)h(goals)f(of)g
(the)h(project)e(is)i(to)g(encourage)d(e)o(xperi-)208
282 y(mentation)f(with)i(the)g(language)e(itself)i(by)g(making)e(it)j
(easier)f(to)g(modify)e(the)i(interpreter)e(\(since)h(it)i(is)g
(written)e(in)h(Python\).)208 382 y(Additional)18 b(information)g(is)j
(a)n(v)n(ailable)f(on)g(the)g(PyPy)g(project')-5 b(s)20
b(home)f(page.)0 612 y(Each)26 b(of)h(these)f(implementations)f(v)n
(aries)i(in)g(some)f(w)o(ay)h(from)e(the)i(language)e(as)j(documented)c
(in)i(this)i(manual,)f(or)f(introduces)0 711 y(speci\002c)17
b(information)e(be)o(yond)g(what')-5 b(s)17 b(co)o(v)o(ered)e(in)i(the)
g(standard)f(Python)g(documentation.)21 b(Please)d(refer)e(to)h(the)g
(implementation-)0 811 y(speci\002c)j(documentation)e(to)i(determine)f
(what)h(else)h(you)e(need)h(to)g(kno)n(w)f(about)g(the)h(speci\002c)h
(implementation)d(you')l(re)g(using.)0 1138 y Fm(1.2)121
b(Notation)0 1371 y Ft(The)23 b(descriptions)e(of)i(le)o(xical)g
(analysis)g(and)f(syntax)g(use)h(a)h(modi\002ed)d(BNF)j(grammar)e
(notation.)31 b(This)23 b(uses)h(the)f(follo)n(wing)e(style)0
1471 y(of)f(de\002nition:)216 1597 y Fo(name)348 b Ft(::=)99
b Fo(lc_letter)49 b(\(lc_letter)e(|)j("_"\))2302 1612
y(*)216 1697 y(lc_letter)98 b Ft(::=)h Fo("a"..."z")0
1839 y Ft(The)21 b(\002rst)i(line)f(says)g(that)g(a)g
Fo(name)g Ft(is)h(an)e Fo(lc_letter)g Ft(follo)n(wed)f(by)i(a)g
(sequence)f(of)g(zero)g(or)h(more)f Fo(lc_letter)p Ft(s)g(and)g(under)n
(-)0 1938 y(scores.)35 b(An)24 b Fo(lc_letter)f Ft(in)g(turn)g(is)i(an)
o(y)e(of)g(the)h(single)f(characters)g(`)p Fo(a)p Ft(')g(through)f(`)p
Fo(z)p Ft('.)35 b(\(This)23 b(rule)h(is)g(actually)f(adhered)f(to)i
(for)0 2038 y(the)c(names)g(de\002ned)f(in)i(le)o(xical)e(and)h
(grammar)f(rules)h(in)g(this)h(document.\))0 2185 y(Each)g(rule)h(be)o
(gins)e(with)i(a)g(name)f(\(which)g(is)i(the)e(name)g(de\002ned)g(by)g
(the)h(rule\))f(and)g Fo(::=)p Ft(.)29 b(A)23 b(v)o(ertical)e(bar)g(\()
p Fo(|)p Ft(\))g(is)i(used)e(to)h(separate)0 2285 y(alternati)n(v)o
(es;)d(it)h(is)g(the)g(least)g(binding)e(operator)f(in)j(this)g
(notation.)j(A)d(star)g(\()2219 2300 y Fo(*)2269 2285
y Ft(\))g(means)f(zero)g(or)g(more)f(repetitions)h(of)g(the)h
(preceding)0 2384 y(item;)j(lik)o(e)n(wise,)g(a)f(plus)g(\()p
Fo(+)p Ft(\))g(means)g(one)f(or)h(more)f(repetitions,)g(and)h(a)g
(phrase)f(enclosed)g(in)i(square)e(brack)o(ets)g(\()p
Fo([)49 b(])p Ft(\))22 b(means)g(zero)0 2484 y(or)c(one)g(occurrences)f
(\(in)h(other)g(w)o(ords,)g(the)h(enclosed)e(phrase)h(is)i(optional\).)
i(The)2421 2499 y Fo(*)2490 2484 y Ft(and)c Fo(+)g Ft(operators)g(bind)
f(as)j(tightly)e(as)h(possible;)0 2583 y(parentheses)i(are)h(used)f
(for)h(grouping.)27 b(Literal)22 b(strings)g(are)g(enclosed)f(in)h
(quotes.)30 b(White)22 b(space)g(is)h(only)e(meaningful)f(to)i
(separate)0 2683 y(tok)o(ens.)44 b(Rules)27 b(are)g(normally)e
(contained)g(on)h(a)h(single)g(line;)j(rules)d(with)f(man)o(y)g
(alternati)n(v)o(es)f(may)i(be)f(formatted)f(alternati)n(v)o(ely)0
2783 y(with)20 b(each)g(line)h(after)e(the)i(\002rst)f(be)o(ginning)e
(with)i(a)h(v)o(ertical)f(bar)-5 b(.)0 2930 y(In)18 b(le)o(xical)h
(de\002nitions)e(\(as)j(the)e(e)o(xample)f(abo)o(v)o(e\),)g(tw)o(o)i
(more)f(con)m(v)o(entions)e(are)i(used:)25 b(T)-7 b(w)o(o)18
b(literal)h(characters)f(separated)g(by)g(three)0 3029
y(dots)e(mean)g(a)h(choice)f(of)g(an)o(y)g(single)g(character)g(in)g
(the)h(gi)n(v)o(en)e(\(inclusi)n(v)o(e\))g(range)h(of)i
Fl(A)t(S)t(C)t(I)t(I)i Ft(characters.)j(A)17 b(phrase)e(between)h
(angular)0 3129 y(brack)o(ets)21 b(\()p Fo(<...>)p Ft(\))g(gi)n(v)o(es)
g(an)g(informal)g(description)f(of)h(the)h(symbol)f(de\002ned;)g(e.g.,)
g(this)i(could)d(be)i(used)f(to)h(describe)f(the)h(notion)0
3228 y(of)e(`control)f(character')f(if)j(needed.)0 3375
y(Ev)o(en)32 b(though)e(the)j(notation)e(used)h(is)i(almost)f(the)f
(same,)k(there)c(is)h(a)g(big)g(dif)n(ference)d(between)i(the)h
(meaning)e(of)h(le)o(xical)g(and)0 3475 y(syntactic)e(de\002nitions:)44
b(a)30 b(le)o(xical)g(de\002nition)f(operates)g(on)h(the)g(indi)n
(vidual)e(characters)h(of)h(the)g(input)f(source,)j(while)e(a)g(syntax)
0 3575 y(de\002nition)d(operates)g(on)h(the)g(stream)g(of)g(tok)o(ens)g
(generated)e(by)i(the)g(le)o(xical)g(analysis.)49 b(All)29
b(uses)g(of)f(BNF)h(in)f(the)g(ne)o(xt)g(chapter)0 3674
y(\(\223Le)o(xical)19 b(Analysis\224\))h(are)g(le)o(xical)g
(de\002nitions;)f(uses)i(in)f(subsequent)f(chapters)g(are)i(syntactic)e
(de\002nitions.)p 0 5549 3901 4 v 0 5649 a Fp(2)2981
b(Chapter)23 b(1.)52 b(Introduction)p eop end
%%Page: 3 9
TeXDict begin 3 8 bop 0 83 3901 9 v 3503 230 a Fp(CHAPTER)3623
427 y Fn(TW)n(O)p 0 515 V 2460 978 a Fz(Le)-6 b(xical)57
b(analysis)0 1466 y Ft(A)19 b(Python)e(program)f(is)j(read)f(by)g(a)h
Fq(par)o(ser)p Ft(.)25 b(Input)17 b(to)h(the)h(parser)e(is)j(a)f
(stream)f(of)g Fq(tok)o(ens)p Ft(,)g(generated)f(by)h(the)g
Fq(le)n(xical)h(analyzer)p Ft(.)k(This)0 1566 y(chapter)c(describes)h
(ho)n(w)f(the)i(le)o(xical)e(analyzer)g(breaks)h(a)g(\002le)h(into)f
(tok)o(ens.)0 1713 y(Python)27 b(uses)i(the)g(7-bit)g
Fl(A)t(S)t(C)t(I)t(I)j Ft(character)c(set)h(for)f(program)e(te)o(xt.)
100 b(Ne)n(w)28 b(in)h(v)o(ersion)e(2.3:)h(An)g(encoding)f(declaration)
f(can)j(be)0 1812 y(used)20 b(to)g(indicate)f(that)h(string)g(literals)
g(and)f(comments)g(use)h(an)g(encoding)e(dif)n(ferent)g(from)h(ASCII.)
40 b(F)o(or)20 b(compatibility)e(with)i(older)0 1912
y(v)o(ersions,)29 b(Python)f(only)g(w)o(arns)g(if)h(it)g(\002nds)g
(8-bit)f(characters;)k(those)c(w)o(arnings)g(should)g(be)g(corrected)f
(by)h(either)h(declaring)e(an)0 2012 y(e)o(xplicit)20
b(encoding,)d(or)j(using)g(escape)g(sequences)f(if)i(those)f(bytes)g
(are)g(binary)f(data,)h(instead)g(of)g(characters.)0
2159 y(The)g(run-time)f(character)f(set)j(depends)e(on)h(the)g(I/O)h
(de)n(vices)e(connected)g(to)h(the)g(program)e(b)n(ut)i(is)i(generally)
c(a)j(superset)f(of)i Fl(A)t(S)t(C)t(I)t(I)r Ft(.)0 2305
y Fr(Futur)o(e)j(compatibility)g(note:)36 b Ft(It)26
b(may)f(be)h(tempting)e(to)i(assume)g(that)g(the)g(character)e(set)j
(for)e(8-bit)g(characters)g(is)i(ISO)f(Latin-1)0 2405
y(\(an)c Fl(A)t(S)t(C)t(I)t(I)j Ft(superset)20 b(that)h(co)o(v)o(ers)f
(most)h(western)g(languages)e(that)i(use)g(the)g(Latin)g(alphabet\),)e
(b)n(ut)i(it)g(is)h(possible)f(that)g(in)g(the)g(future)0
2505 y(Unicode)d(te)o(xt)h(editors)g(will)h(become)e(common.)23
b(These)c(generally)f(use)h(the)h(UTF-8)e(encoding,)g(which)g(is)j
(also)e(an)i Fl(A)t(S)t(C)t(I)t(I)i Ft(superset,)0 2604
y(b)n(ut)d(with)f(v)o(ery)g(dif)n(ferent)f(use)i(for)f(the)g
(characters)g(with)h(ordinals)f(128-255.)j(While)e(there)f(is)h(no)g
(consensus)f(on)g(this)h(subject)f(yet,)h(it)0 2704 y(is)k(unwise)e(to)
h(assume)g(either)f(Latin-1)g(or)g(UTF-8,)h(e)n(v)o(en)f(though)f(the)i
(current)e(implementation)g(appears)h(to)g(f)o(a)n(v)n(or)h(Latin-1.)31
b(This)0 2804 y(applies)20 b(both)f(to)i(the)f(source)f(character)g
(set)i(and)f(the)g(run-time)f(character)g(set.)0 3131
y Fm(2.1)121 b(Line)34 b(str)r(ucture)0 3364 y Ft(A)21
b(Python)e(program)f(is)j(di)n(vided)e(into)h(a)g(number)f(of)g
Fq(lo)o(gical)h(lines)p Ft(.)0 3649 y Fk(2.1.1)100 b(Logical)29
b(lines)0 3852 y Ft(The)h(end)f(of)h(a)g(logical)f(line)h(is)h
(represented)d(by)i(the)g(tok)o(en)f(NEWLINE.)g(Statements)h(cannot)f
(cross)h(logical)g(line)g(boundaries)0 3951 y(e)o(xcept)21
b(where)g(NEWLINE)g(is)i(allo)n(wed)e(by)h(the)f(syntax)h(\(e.g.,)f
(between)g(statements)h(in)f(compound)e(statements\).)30
b(A)22 b(logical)f(line)0 4051 y(is)g(constructed)e(from)g(one)g(or)h
(more)g Fq(physical)f(lines)i Ft(by)e(follo)n(wing)g(the)h(e)o(xplicit)
g(or)g(implicit)g Fq(line)g(joining)f Ft(rules.)0 4336
y Fk(2.1.2)100 b(Ph)m(ysical)29 b(lines)0 4539 y Ft(A)21
b(physical)f(line)h(is)g(a)h(sequence)d(of)i(characters)e(terminated)h
(by)g(an)h(end-of-line)d(sequence.)25 b(In)c(source)f(\002les,)i(an)o
(y)d(of)i(the)g(standard)0 4638 y(platform)d(line)j(termination)d
(sequences)h(can)h(be)g(used)f(-)i(the)h(U)t Fl(N)t(I)t(X)h
Ft(form)18 b(using)k Fl(A)t(S)t(C)t(I)t(I)h Ft(LF)e(\(linefeed\),)d
(the)i(W)m(indo)n(ws)f(form)g(using)0 4738 y(the)h Fl(A)t(S)t(C)t(I)t
(I)h Ft(sequence)c(CR)i(LF)g(\(return)d(follo)n(wed)g(by)i(linefeed\),)
f(or)g(the)h(Macintosh)f(form)g(using)g(the)j Fl(A)t(S)t(C)t(I)t(I)h
Ft(CR)f(\(return\))c(character)-5 b(.)0 4838 y(All)21
b(of)f(these)g(forms)g(can)g(be)g(used)g(equally)-5 b(,)18
b(re)o(gardless)h(of)h(platform.)0 4984 y(When)i(embedding)d(Python,)i
(source)g(code)h(strings)g(should)f(be)h(passed)f(to)i(Python)d(APIs)j
(using)e(the)h(standard)f(C)i(con)m(v)o(entions)c(for)0
5084 y(ne)n(wline)h(characters)f(\(the)h Fo(\\n)g Ft(character)m(,)e
(representing)j Fl(A)t(S)t(C)t(I)t(I)i Ft(LF)-7 b(,)21
b(is)g(the)f(line)h(terminator\).)p 0 5549 3901 4 v 3854
5649 a Fp(3)p eop end
%%Page: 4 10
TeXDict begin 4 9 bop 0 83 a Fk(2.1.3)100 b(Comments)0
286 y Ft(A)19 b(comment)e(starts)i(with)g(a)f(hash)g(character)g(\()p
Fo(#)p Ft(\))g(that)g(is)h(not)f(part)g(of)g(a)h(string)f(literal,)h
(and)f(ends)g(at)h(the)f(end)g(of)g(the)g(physical)g(line.)24
b(A)0 386 y(comment)19 b(signi\002es)i(the)f(end)g(of)h(the)f(logical)g
(line)h(unless)f(the)h(implicit)f(line)h(joining)e(rules)i(are)f(in)m
(v)n(ok)o(ed.)k(Comments)c(are)g(ignored)0 485 y(by)g(the)g(syntax;)g
(the)o(y)f(are)h(not)g(tok)o(ens.)0 770 y Fk(2.1.4)100
b(Encoding)30 b(declar)o(ations)0 973 y Ft(If)76 b(a)h(comment)d(in)j
(the)f(\002rst)h(or)f(second)f(line)h(of)g(the)g(Python)f(script)i
(matches)e(the)i(re)o(gular)d(e)o(xpression)0 1039 y
Fj(d)16 1073 y Fo(coding[=:]\\s)616 1088 y(*)666 1073
y(\([-\\w.]+\))-10 b Fj(c)g Ft(,)35 b(this)i(comment)e(is)i(processed)f
(as)h(an)f(encoding)e(declaration;)43 b(the)36 b(\002rst)h(group)e(of)h
(this)0 1172 y(e)o(xpression)19 b(names)g(the)i(encoding)d(of)i(the)g
(source)f(code)h(\002le.)25 b(The)20 b(recommended)d(forms)j(of)g(this)
g(e)o(xpression)f(are)236 1410 y Fi(#)45 b(-)371 1423
y(*)416 1410 y(-)f(coding:)g(<encoding-name>)e(-)1626
1423 y(*)1671 1410 y(-)0 1697 y Ft(which)20 b(is)h(recognized)d(also)i
(by)g(GNU)h(Emacs,)e(and)236 1935 y Fi(#)45 b
(vim:fileencoding=<encoding-name>)0 2222 y Ft(which)17
b(is)i(recognized)d(by)i(Bram)g(Moolenaar')-5 b(s)17
b(VIM.)g(In)h(addition,)f(if)h(the)g(\002rst)h(bytes)f(of)g(the)g
(\002le)g(are)g(the)g(UTF-8)g(byte-order)d(mark)0 2321
y(\()p Fo('\\xef\\xbb\\xbf')p Ft(\),)g(the)i(declared)f(\002le)i
(encoding)d(is)j(UTF-8)f(\(this)h(is)g(supported,)d(among)h(others,)h
(by)g(Microsoft')-5 b(s)17 b Fr(notepad)p Ft(\).)0 2468
y(If)26 b(an)h(encoding)d(is)k(declared,)f(the)f(encoding)f(name)h
(must)g(be)h(recognized)d(by)i(Python.)43 b(The)26 b(encoding)f(is)i
(used)g(for)f(all)h(le)o(xical)0 2568 y(analysis,)f(in)f(particular)f
(to)h(\002nd)f(the)h(end)g(of)f(a)i(string,)f(and)g(to)g(interpret)e
(the)i(contents)g(of)f(Unicode)g(literals.)40 b(String)24
b(literals)i(are)0 2667 y(con)m(v)o(erted)h(to)j(Unicode)f(for)h
(syntactical)f(analysis,)j(then)e(con)m(v)o(erted)d(back)j(to)g(their)f
(original)g(encoding)f(before)h(interpretation)0 2767
y(starts.)d(The)20 b(encoding)e(declaration)g(must)j(appear)e(on)g(a)i
(line)f(of)g(its)h(o)n(wn.)0 3052 y Fk(2.1.5)100 b(Explicit)28
b(line)h(joining)0 3255 y Ft(T)-7 b(w)o(o)17 b(or)g(more)g(physical)f
(lines)h(may)g(be)g(joined)f(into)h(logical)g(lines)h(using)e
(backslash)h(characters)f(\()p Fo(\\)p Ft(\),)h(as)h(follo)n(ws:)24
b(when)16 b(a)i(physical)0 3354 y(line)k(ends)f(in)h(a)h(backslash)e
(that)h(is)g(not)g(part)f(of)h(a)g(string)f(literal)h(or)g(comment,)f
(it)h(is)h(joined)e(with)h(the)f(follo)n(wing)g(forming)e(a)k(single)0
3454 y(logical)d(line,)g(deleting)f(the)h(backslash)g(and)f(the)i
(follo)n(wing)d(end-of-line)g(character)-5 b(.)24 b(F)o(or)c(e)o
(xample:)236 3692 y Fi(if)45 b(1900)f(<)h(year)f(<)g(2100)h(and)f(1)h
(<=)f(month)g(<=)g(12)h(\\)371 3784 y(and)f(1)h(<=)f(day)h(<=)f(31)h
(and)f(0)h(<=)f(hour)g(<)h(24)f(\\)371 3875 y(and)g(0)h(<=)f(minute)g
(<)h(60)f(and)h(0)f(<=)h(second)e(<)i(60:)134 b(#)45
b(Looks)f(like)g(a)h(valid)f(date)595 3966 y(return)g(1)0
4253 y Ft(A)24 b(line)f(ending)f(in)i(a)g(backslash)f(cannot)f(carry)g
(a)i(comment.)33 b(A)24 b(backslash)f(does)g(not)g(continue)f(a)i
(comment.)33 b(A)24 b(backslash)f(does)0 4352 y(not)c(continue)f(a)i
(tok)o(en)f(e)o(xcept)g(for)f(string)i(literals)g(\(i.e.,)f(tok)o(ens)g
(other)g(than)g(string)g(literals)h(cannot)f(be)g(split)h(across)g
(physical)e(lines)0 4452 y(using)i(a)g(backslash\).)k(A)d(backslash)e
(is)j(ille)o(gal)d(else)n(where)h(on)g(a)g(line)g(outside)g(a)h(string)
f(literal.)0 4737 y Fk(2.1.6)100 b(Implicit)28 b(line)h(joining)0
4940 y Ft(Expressions)17 b(in)h(parentheses,)f(square)g(brack)o(ets)g
(or)h(curly)f(braces)g(can)h(be)g(split)g(o)o(v)o(er)f(more)g(than)g
(one)g(physical)g(line)h(without)f(using)0 5039 y(backslashes.)24
b(F)o(or)c(e)o(xample:)p 0 5549 3901 4 v 0 5649 a Fp(4)2836
b(Chapter)23 b(2.)52 b(Le)n(xical)23 b(analysis)p eop
end
%%Page: 5 11
TeXDict begin 5 10 bop 236 174 a Fi(month_names)43 b(=)i(['Januari',)e
('Februari',)g('Maart',)267 b(#)45 b(These)f(are)g(the)909
266 y('April',)133 b('Mei',)268 b('Juni',)312 b(#)45
b(Dutch)f(names)909 357 y('Juli',)178 b('Augustus',)43
b('September',)87 b(#)45 b(for)f(the)h(months)909 448
y('Oktober',)e('November',)g('December'])132 b(#)45 b(of)g(the)f(year)0
735 y Ft(Implicitly)28 b(continued)f(lines)j(can)f(carry)f(comments.)51
b(The)29 b(indentation)e(of)i(the)g(continuation)e(lines)i(is)i(not)d
(important.)51 b(Blank)0 834 y(continuation)15 b(lines)j(are)g(allo)n
(wed.)23 b(There)17 b(is)i(no)e(NEWLINE)h(tok)o(en)e(between)h
(implicit)h(continuation)d(lines.)25 b(Implicitly)17
b(continued)0 934 y(lines)k(can)f(also)g(occur)f(within)h
(triple-quoted)e(strings)i(\(see)g(belo)n(w\);)g(in)g(that)g(case)h
(the)o(y)e(cannot)h(carry)f(comments.)0 1219 y Fk(2.1.7)100
b(Blank)29 b(lines)0 1422 y Ft(A)h(logical)g(line)g(that)g(contains)f
(only)h(spaces,)i(tabs,)g(formfeeds)d(and)g(possibly)g(a)i(comment,)f
(is)h(ignored)e(\(i.e.,)i(no)f(NEWLINE)0 1522 y(tok)o(en)f(is)h
(generated\).)50 b(During)29 b(interacti)n(v)o(e)f(input)g(of)h
(statements,)j(handling)c(of)h(a)h(blank)e(line)h(may)g(dif)n(fer)g
(depending)e(on)i(the)0 1621 y(implementation)c(of)i(the)h(read-e)n(v)n
(al-print)c(loop.)46 b(In)27 b(the)g(standard)f(implementation,)h(an)h
(entirely)e(blank)h(logical)g(line)g(\(i.e.)g(one)0 1721
y(containing)18 b(not)i(e)n(v)o(en)f(whitespace)h(or)g(a)g(comment\))f
(terminates)g(a)i(multi-line)e(statement.)0 2006 y Fk(2.1.8)100
b(Indentation)0 2209 y Ft(Leading)19 b(whitespace)h(\(spaces)h(and)f
(tabs\))g(at)h(the)g(be)o(ginning)d(of)i(a)h(logical)f(line)h(is)h
(used)e(to)h(compute)e(the)h(indentation)f(le)n(v)o(el)h(of)h(the)0
2308 y(line,)f(which)g(in)g(turn)g(is)h(used)f(to)g(determine)f(the)h
(grouping)d(of)j(statements.)0 2455 y(First,)27 b(tabs)e(are)f
(replaced)g(\(from)f(left)i(to)g(right\))f(by)h(one)f(to)h(eight)f
(spaces)h(such)g(that)g(the)f(total)h(number)e(of)i(characters)f(up)g
(to)h(and)0 2555 y(including)h(the)i(replacement)e(is)j(a)f(multiple)g
(of)f(eight)h(\(this)g(is)h(intended)d(to)i(be)g(the)g(same)g(rule)f
(as)i(used)f(by)h(U)t Fl(N)t(I)t(X)r Ft(\).)49 b(The)27
b(total)0 2654 y(number)17 b(of)i(spaces)h(preceding)d(the)i(\002rst)h
(non-blank)c(character)i(then)g(determines)g(the)h(line')-5
b(s)20 b(indentation.)j(Indentation)17 b(cannot)h(be)0
2754 y(split)f(o)o(v)o(er)e(multiple)h(physical)g(lines)h(using)f
(backslashes;)h(the)g(whitespace)f(up)g(to)h(the)f(\002rst)i(backslash)
e(determines)f(the)i(indentation.)0 2901 y Fr(Cr)o(oss-platf)n(orm)h
(compatibility)h(note:)25 b Ft(because)19 b(of)h(the)g(nature)f(of)h
(te)o(xt)g(editors)g(on)f(non-UNIX)g(platforms,)f(it)j(is)g(unwise)f
(to)g(use)0 3000 y(a)h(mixture)f(of)g(spaces)h(and)g(tabs)g(for)f(the)h
(indentation)e(in)i(a)g(single)g(source)f(\002le.)27
b(It)21 b(should)f(also)h(be)g(noted)f(that)h(dif)n(ferent)e(platforms)
0 3100 y(may)h(e)o(xplicitly)f(limit)i(the)f(maximum)e(indentation)h
(le)n(v)o(el.)0 3247 y(A)k(formfeed)d(character)h(may)g(be)h(present)g
(at)h(the)f(start)g(of)g(the)h(line;)g(it)g(will)g(be)f(ignored)e(for)i
(the)g(indentation)e(calculations)h(abo)o(v)o(e.)0 3347
y(F)o(ormfeed)h(characters)h(occurring)e(else)n(where)i(in)h(the)g
(leading)f(whitespace)g(ha)n(v)o(e)g(an)h(unde\002ned)e(ef)n(fect)h
(\(for)g(instance,)h(the)o(y)f(may)0 3446 y(reset)d(the)h(space)f
(count)f(to)h(zero\).)0 3593 y(The)29 b(indentation)f(le)n(v)o(els)i
(of)f(consecuti)n(v)o(e)f(lines)i(are)f(used)h(to)g(generate)e(INDENT)h
(and)g(DEDENT)g(tok)o(ens,)j(using)d(a)h(stack,)i(as)0
3693 y(follo)n(ws.)0 3840 y(Before)23 b(the)h(\002rst)h(line)e(of)h
(the)g(\002le)g(is)h(read,)f(a)g(single)g(zero)f(is)i(pushed)d(on)i
(the)f(stack;)j(this)f(will)f(ne)n(v)o(er)f(be)g(popped)f(of)n(f)h
(again.)35 b(The)0 3939 y(numbers)22 b(pushed)g(on)h(the)g(stack)h
(will)g(al)o(w)o(ays)f(be)h(strictly)f(increasing)f(from)h(bottom)f(to)
h(top.)34 b(At)24 b(the)f(be)o(ginning)e(of)i(each)g(logical)0
4039 y(line,)f(the)g(line')-5 b(s)22 b(indentation)e(le)n(v)o(el)h(is)i
(compared)d(to)i(the)f(top)h(of)f(the)h(stack.)30 b(If)21
b(it)i(is)g(equal,)e(nothing)f(happens.)28 b(If)22 b(it)g(is)h(lar)o
(ger)m(,)d(it)j(is)0 4138 y(pushed)d(on)g(the)h(stack,)g(and)g(one)f
(INDENT)h(tok)o(en)f(is)i(generated.)j(If)c(it)h(is)f(smaller)m(,)g(it)
h Fq(must)f Ft(be)g(one)f(of)h(the)g(numbers)e(occurring)g(on)0
4238 y(the)g(stack;)h(all)f(numbers)f(on)h(the)g(stack)g(that)g(are)g
(lar)o(ger)f(are)h(popped)e(of)n(f,)h(and)h(for)f(each)h(number)e
(popped)g(of)n(f)h(a)i(DEDENT)e(tok)o(en)h(is)0 4338
y(generated.)25 b(At)d(the)f(end)f(of)h(the)g(\002le,)g(a)h(DEDENT)e
(tok)o(en)g(is)i(generated)d(for)i(each)f(number)f(remaining)g(on)i
(the)g(stack)g(that)g(is)h(lar)o(ger)0 4437 y(than)e(zero.)0
4584 y(Here)g(is)h(an)f(e)o(xample)f(of)h(a)h(correctly)d(\(though)g
(confusingly\))g(indented)h(piece)h(of)f(Python)g(code:)p
0 5549 3901 4 v 0 5649 a Fp(2.1.)52 b(Line)24 b(str)q(ucture)3159
b(5)p eop end
%%Page: 6 12
TeXDict begin 6 11 bop 236 174 a Fi(def)45 b(perm\(l\):)595
266 y(#)g(Compute)e(the)i(list)f(of)g(all)h(permutations)d(of)j(l)416
357 y(if)f(len\(l\))g(<=)g(1:)1043 448 y(return)g([l])416
540 y(r)g(=)h([])416 631 y(for)f(i)h(in)f(range\(len\(l\)\):)819
722 y(s)h(=)f(l[:i])g(+)h(l[i+1:])819 814 y(p)g(=)f(perm\(s\))819
905 y(for)g(x)h(in)g(p:)864 996 y(r.append\(l[i:i+1])d(+)j(x\))416
1088 y(return)e(r)0 1374 y Ft(The)20 b(follo)n(wing)e(e)o(xample)h(sho)
n(ws)h(v)n(arious)g(indentation)e(errors:)281 1612 y
Fi(def)44 b(perm\(l\):)1030 b(#)45 b(error:)f(first)g(line)g(indented)
236 1704 y(for)h(i)f(in)h(range\(len\(l\)\):)580 b(#)45
b(error:)f(not)g(indented)416 1795 y(s)g(=)h(l[:i])f(+)h(l[i+1:])595
1886 y(p)g(=)f(perm\(l[:i])f(+)i(l[i+1:]\))133 b(#)45
b(error:)f(unexpected)f(indent)595 1978 y(for)h(x)h(in)f(p:)954
2069 y(r.append\(l[i:i+1])e(+)i(x\))774 2160 y(return)g(r)717
b(#)45 b(error:)f(inconsistent)e(dedent)0 2447 y Ft(\(Actually)-5
b(,)25 b(the)g(\002rst)i(three)d(errors)h(are)g(detected)g(by)g(the)g
(parser;)i(only)e(the)g(last)h(error)e(is)j(found)c(by)i(the)h(le)o
(xical)f(analyzer)f(\227)i(the)0 2546 y(indentation)18
b(of)i Fo(return)49 b(r)21 b Ft(does)e(not)h(match)g(a)h(le)n(v)o(el)e
(popped)g(of)n(f)g(the)h(stack.\))0 2831 y Fk(2.1.9)100
b(Whitespace)29 b(betw)o(een)h(tok)n(ens)0 3034 y Ft(Except)20
b(at)g(the)h(be)o(ginning)d(of)i(a)h(logical)f(line)g(or)g(in)h(string)
f(literals,)h(the)f(whitespace)g(characters)g(space,)g(tab)g(and)g
(formfeed)e(can)j(be)0 3134 y(used)h(interchangeably)d(to)k(separate)f
(tok)o(ens.)31 b(Whitespace)22 b(is)i(needed)d(between)g(tw)o(o)i(tok)o
(ens)f(only)g(if)g(their)g(concatenation)f(could)0 3233
y(otherwise)f(be)g(interpreted)e(as)j(a)g(dif)n(ferent)d(tok)o(en)i
(\(e.g.,)f(ab)h(is)h(one)e(tok)o(en,)h(b)n(ut)g(a)g(b)h(is)g(tw)o(o)f
(tok)o(ens\).)0 3561 y Fm(2.2)121 b(Other)34 b(tok)n(ens)0
3794 y Ft(Besides)24 b(NEWLINE,)e(INDENT)g(and)g(DEDENT)-6
b(,)22 b(the)h(follo)n(wing)e(cate)o(gories)g(of)i(tok)o(ens)f(e)o
(xist:)30 b Fq(identi\002er)o(s)p Ft(,)23 b Fq(k)o(e)n(ywor)m(ds)p
Ft(,)g Fq(liter)o(als)p Ft(,)0 3893 y Fq(oper)o(ator)o(s)p
Ft(,)j(and)g Fq(delimiter)o(s)p Ft(.)43 b(Whitespace)26
b(characters)f(\(other)f(than)i(line)g(terminators,)g(discussed)f
(earlier\))g(are)h(not)g(tok)o(ens,)h(b)n(ut)0 3993 y(serv)o(e)18
b(to)g(delimit)g(tok)o(ens.)24 b(Where)18 b(ambiguity)e(e)o(xists,)j(a)
g(tok)o(en)e(comprises)g(the)i(longest)e(possible)h(string)g(that)g
(forms)g(a)g(le)o(gal)g(tok)o(en,)0 4093 y(when)i(read)f(from)g(left)i
(to)f(right.)0 4420 y Fm(2.3)121 b(Identi\002ers)34 b(and)h(k)n(e)n(yw)
o(ords)0 4653 y Ft(Identi\002ers)19 b(\(also)i(referred)d(to)i(as)h
Fq(names)p Ft(\))f(are)g(described)f(by)h(the)g(follo)n(wing)e(le)o
(xical)i(de\002nitions:)216 4796 y Fo(identifier)98 b
Ft(::=)h Fo(\(letter|"_"\))48 b(\(letter)g(|)i(digit)f(|)g("_"\))2750
4811 y(*)216 4896 y(letter)298 b Ft(::=)99 b Fo(lowercase)48
b(|)i(uppercase)216 4995 y(lowercase)148 b Ft(::=)99
b Fo("a"..."z")216 5095 y(uppercase)148 b Ft(::=)99 b
Fo("A"..."Z")216 5195 y(digit)348 b Ft(::=)99 b Fo("0"..."9")0
5337 y Ft(Identi\002ers)19 b(are)i(unlimited)e(in)h(length.)k(Case)d
(is)g(signi\002cant.)p 0 5549 3901 4 v 0 5649 a Fp(6)2836
b(Chapter)23 b(2.)52 b(Le)n(xical)23 b(analysis)p eop
end
%%Page: 7 13
TeXDict begin 7 12 bop 0 83 a Fk(2.3.1)100 b(K)l(e)n(yw)o(ords)0
286 y Ft(The)27 b(follo)n(wing)e(identi\002ers)i(are)g(used)g(as)h
(reserv)o(ed)e(w)o(ords,)i(or)f Fq(k)o(e)n(ywor)m(ds)g
Ft(of)g(the)g(language,)g(and)g(cannot)f(be)h(used)g(as)h(ordinary)0
386 y(identi\002ers.)d(The)o(y)19 b(must)h(be)g(spelled)g(e)o(xactly)f
(as)i(written)f(here:)236 624 y Fi(and)314 b(del)f(from)268
b(not)313 b(while)236 715 y(as)359 b(elif)268 b(global)178
b(or)358 b(with)236 806 y(assert)179 b(else)268 b(if)358
b(pass)268 b(yield)236 898 y(break)224 b(except)178 b(import)g(print)
236 989 y(class)224 b(exec)268 b(in)358 b(raise)236 1080
y(continue)89 b(finally)133 b(is)358 b(return)236 1172
y(def)314 b(for)f(lambda)178 b(try)0 1458 y Ft(Changed)24
b(in)h(v)o(ersion)f(2.4:)h Fo(None)g Ft(became)g(a)g(constant)g(and)g
(is)h(no)n(w)f(recognized)e(by)i(the)g(compiler)f(as)i(a)g(name)e(for)h
(the)g(b)n(uilt-in)0 1558 y(object)20 b Fo(None)p Ft(.)k(Although)19
b(it)i(is)g(not)f(a)g(k)o(e)o(yw)o(ord,)e(you)i(cannot)f(assign)h(a)h
(dif)n(ferent)d(object)i(to)g(it.)0 1705 y(Changed)27
b(in)h(v)o(ersion)f(2.5:)g(Both)i Fo(as)f Ft(and)f Fo(with)h
Ft(are)g(only)g(recognized)e(when)h(the)h Fo(with_statement)e
Ft(future)h(feature)g(has)0 1804 y(been)c(enabled.)35
b(It)24 b(will)g(al)o(w)o(ays)g(be)g(enabled)f(in)h(Python)e(2.6.)35
b(See)24 b(section)g(7.5)f(for)g(details.)36 b(Note)24
b(that)g(using)f Fo(as)h Ft(and)f Fo(with)h Ft(as)0 1904
y(identi\002ers)c(will)h(al)o(w)o(ays)f(issue)h(a)g(w)o(arning,)e(e)n
(v)o(en)g(when)g(the)i Fo(with_statement)d Ft(future)h(directi)n(v)o(e)
g(is)i(not)f(in)g(ef)n(fect.)0 2189 y Fk(2.3.2)100 b(Reser)s(v)n(ed)29
b(classes)f(of)f(identi\002ers)0 2392 y Ft(Certain)19
b(classes)h(of)f(identi\002ers)g(\(besides)g(k)o(e)o(yw)o(ords\))e(ha)n
(v)o(e)h(special)i(meanings.)j(These)c(classes)h(are)f(identi\002ed)f
(by)h(the)g(patterns)g(of)0 2491 y(leading)g(and)h(trailing)f
(underscore)f(characters:)0 2721 y Fh(_)50 2734 y(*)141
2721 y Ft(Not)23 b(imported)e(by)i(`)p Fo(from)48 b Fq(module)h
Fo(import)1638 2736 y(*)1688 2721 y Ft('.)33 b(The)23
b(special)g(identi\002er)f(`)p Fo(_)p Ft(')g(is)i(used)f(in)g(the)g
(interacti)n(v)o(e)e(interpreter)g(to)208 2821 y(store)f(the)h(result)f
(of)g(the)h(last)g(e)n(v)n(aluation;)e(it)i(is)h(stored)e(in)g(the)h
Fo(__builtin__)e Ft(module.)24 b(When)d(not)f(in)h(interacti)n(v)o(e)e
(mode,)208 2921 y(`)p Fo(_)p Ft(')g(has)i(no)f(special)g(meaning)f(and)
g(is)i(not)f(de\002ned.)k(See)d(section)f(6.12,)f(\223The)g
Fo(import)h Ft(statement.)-6 b(\224)208 3053 y Fr(Note:)33
b Ft(The)25 b(name)f(`)p Fo(_)p Ft(')h(is)h(often)e(used)g(in)h
(conjunction)e(with)i(internationalization;)f(refer)g(to)h(the)g
(documentation)d(for)j(the)208 3153 y Fo(gettext)19 b
Ft(module)g(for)g(more)h(information)e(on)h(this)i(con)m(v)o(ention.)0
3319 y Fh(__)100 3332 y(*)150 3319 y(__)41 b Ft(System-de\002ned)27
b(names.)52 b(These)29 b(names)g(are)g(de\002ned)f(by)h(the)h
(interpreter)d(and)i(its)h(implementation)d(\(including)h(the)208
3419 y(standard)c(library\);)i(applications)f(should)f(not)h(e)o(xpect)
g(to)g(de\002ne)g(additional)f(names)h(using)g(this)h(con)m(v)o
(ention.)38 b(The)25 b(set)h(of)208 3518 y(names)g(of)g(this)h(class)g
(de\002ned)f(by)g(Python)f(may)h(be)g(e)o(xtended)f(in)h(future)g(v)o
(ersions.)42 b(See)27 b(section)g(3.4,)g(\223Special)f(method)208
3618 y(names.)-6 b(\224)0 3784 y Fh(__)100 3797 y(*)191
3784 y Ft(Class-pri)n(v)n(ate)23 b(names.)36 b(Names)23
b(in)h(this)h(cate)o(gory)-5 b(,)22 b(when)h(used)g(within)h(the)g
(conte)o(xt)e(of)i(a)g(class)h(de\002nition,)e(are)h(re-written)208
3884 y(to)c(use)h(a)g(mangled)e(form)h(to)h(help)f(a)n(v)n(oid)g(name)g
(clashes)h(between)f(\223pri)n(v)n(ate\224)f(attrib)n(utes)i(of)f(base)
h(and)f(deri)n(v)o(ed)f(classes.)27 b(See)208 3983 y(section)20
b(5.2.1,)e(\223Identi\002ers)h(\(Names\).)-6 b(\224)0
4311 y Fm(2.4)121 b(Liter)o(als)0 4543 y Ft(Literals)20
b(are)h(notations)e(for)g(constant)h(v)n(alues)g(of)f(some)h(b)n
(uilt-in)g(types.)0 4828 y Fk(2.4.1)100 b(Str)q(ing)30
b(liter)o(als)0 5031 y Ft(String)20 b(literals)g(are)h(described)d(by)i
(the)g(follo)n(wing)f(le)o(xical)h(de\002nitions:)p 0
5549 3901 4 v 0 5649 a Fp(2.4.)52 b(Liter)o(als)3398
b(7)p eop end
%%Page: 8 14
TeXDict begin 8 13 bop 216 70 a Fo(stringliteral)197
b Ft(::=)99 b Fo([stringprefix]\(shortstring)45 b(|)50
b(longstring\))216 169 y(stringprefix)247 b Ft(::=)99
b Fo("r")50 b(|)f("u")g(|)h("ur")f(|)h("R")f(|)h("U")f(|)g("UR")h(|)f
("Ur")g(|)h("uR")216 269 y(shortstring)297 b Ft(::=)99
b Fo("'")50 b(shortstringitem)2205 284 y(*)2301 269 y("'")g(|)f('"')g
(shortstringitem)3549 284 y(*)3646 269 y('"')216 369
y(longstring)347 b Ft(::=)99 b Fo("'''")49 b(longstringitem)2254
384 y(*)2351 369 y("'''")1255 468 y(|)h('"""')f(longstringitem)2354
483 y(*)2451 468 y('"""')216 568 y(shortstringitem)97
b Ft(::=)i Fo(shortstringchar)47 b(|)j(escapeseq)216
667 y(longstringitem)147 b Ft(::=)99 b Fo(longstringchar)47
b(|)j(escapeseq)216 767 y(shortstringchar)97 b Ft(::=)i
Fo(<any)49 b(source)g(character)f(except)h("\\")g(or)h(newline)e(or)i
(the)f(quote>)216 867 y(longstringchar)147 b Ft(::=)99
b Fo(<any)49 b(source)g(character)f(except)h("\\">)216
966 y(escapeseq)397 b Ft(::=)99 b Fo("\\")50 b(<any)f(ASCII)f
(character>)0 1151 y Ft(One)g(syntactic)f(restriction)g(not)g
(indicated)g(by)g(these)h(productions)e(is)i(that)g(whitespace)f(is)i
(not)f(allo)n(wed)f(between)g(the)0 1251 y Fo(stringprefix)20
b Ft(and)i(the)g(rest)h(of)f(the)g(string)f(literal.)31
b(The)22 b(source)f(character)g(set)i(is)g(de\002ned)e(by)h(the)g
(encoding)e(declaration;)i(it)0 1351 y(is)h Fl(A)t(S)t(C)t(I)t(I)h
Ft(if)c(no)g(encoding)e(declaration)h(is)i(gi)n(v)o(en)e(in)h(the)g
(source)g(\002le;)h(see)g(section)f(2.1.4.)0 1498 y(In)h(plain)g
(English:)26 b(String)21 b(literals)g(can)g(be)g(enclosed)g(in)g
(matching)f(single)h(quotes)f(\()p Fo(')p Ft(\))h(or)g(double)e(quotes)
i(\()p Fo(")p Ft(\).)27 b(The)o(y)20 b(can)h(also)h(be)0
1597 y(enclosed)d(in)h(matching)f(groups)g(of)h(three)f(single)h(or)g
(double)f(quotes)g(\(these)h(are)g(generally)f(referred)f(to)i(as)h
Fq(triple-quoted)e(strings)p Ft(\).)0 1697 y(The)30 b(backslash)g(\()p
Fo(\\)p Ft(\))g(character)f(is)j(used)e(to)h(escape)f(characters)g
(that)g(otherwise)g(ha)n(v)o(e)g(a)h(special)g(meaning,)g(such)f(as)h
(ne)n(wline,)0 1796 y(backslash)21 b(itself,)h(or)f(the)h(quote)e
(character)-5 b(.)28 b(String)21 b(literals)h(may)f(optionally)f(be)h
(pre\002x)o(ed)f(with)h(a)h(letter)g(`)p Fo(r)p Ft(')f(or)g(`)p
Fo(R)p Ft(';)g(such)h(strings)0 1896 y(are)d(called)f
Fq(r)o(aw)h(strings)h Ft(and)e(use)h(dif)n(ferent)e(rules)h(for)g
(interpreting)f(backslash)h(escape)h(sequences.)k(A)c(pre\002x)f(of)h
(`)p Fo(u)p Ft(')f(or)g(`)p Fo(U)p Ft(')h(mak)o(es)0
1996 y(the)i(string)g(a)h(Unicode)e(string.)27 b(Unicode)20
b(strings)h(use)g(the)h(Unicode)e(character)g(set)h(as)h(de\002ned)e
(by)h(the)g(Unicode)f(Consortium)g(and)0 2095 y(ISO)28
b(10646.)46 b(Some)28 b(additional)f(escape)g(sequences,)i(described)e
(belo)n(w)-5 b(,)28 b(are)g(a)n(v)n(ailable)g(in)g(Unicode)e(strings.)
49 b(The)27 b(tw)o(o)h(pre\002x)0 2195 y(characters)19
b(may)h(be)g(combined;)e(in)j(this)f(case,)h(`)p Fo(u)p
Ft(')f(must)g(appear)f(before)g(`)p Fo(r)p Ft('.)0 2342
y(In)26 b(triple-quoted)e(strings,)j(unescaped)e(ne)n(wlines)h(and)g
(quotes)f(are)h(allo)n(wed)g(\(and)f(are)i(retained\),)f(e)o(xcept)f
(that)h(three)g(unescaped)0 2441 y(quotes)20 b(in)g(a)g(ro)n(w)g
(terminate)g(the)g(string.)k(\(A)d(\223quote\224)e(is)i(the)f
(character)f(used)h(to)g(open)f(the)i(string,)e(i.e.)25
b(either)20 b Fo(')h Ft(or)f Fo(")p Ft(.\))0 2588 y(Unless)25
b(an)g(`)p Fo(r)p Ft(')f(or)g(`)p Fo(R)p Ft(')g(pre\002x)g(is)i
(present,)e(escape)h(sequences)e(in)i(strings)f(are)h(interpreted)e
(according)f(to)j(rules)f(similar)h(to)g(those)0 2688
y(used)20 b(by)g(Standard)f(C.)h(The)g(recognized)e(escape)i(sequences)
g(are:)397 2889 y Fr(Escape)g(Sequence)p 1047 2919 4
100 v 100 w(Meaning)p 3254 2919 V 1893 w(Notes)p 347
2922 3207 4 v 397 2992 a Fo(\\)p Fq(ne)o(wline)p 1047
3022 4 100 v 393 w Ft(Ignored)p 3254 3022 V 397 3091
a Fo(\\\\)p 1047 3121 V 601 w Ft(Backslash)h(\()p Fo(\\)p
Ft(\))p 3254 3121 V 397 3191 a Fo(\\')p 1047 3221 V 601
w Ft(Single)f(quote)f(\()p Fo(')p Ft(\))p 3254 3221 V
397 3291 a Fo(\\")p 1047 3320 V 601 w Ft(Double)g(quote)h(\()p
Fo(")p Ft(\))p 3254 3320 V 397 3390 a Fo(\\a)p 1047 3420
V 603 w Fl(A)t(S)t(C)t(I)t(I)k Ft(Bell)d(\(BEL\))p 3254
3420 V 397 3490 a Fo(\\b)p 1047 3520 V 603 w Fl(A)t(S)t(C)t(I)t(I)j
Ft(Backspace)c(\(BS\))p 3254 3520 V 397 3589 a Fo(\\f)p
1047 3619 V 603 w Fl(A)t(S)t(C)t(I)t(I)k Ft(F)o(ormfeed)18
b(\(FF\))p 3254 3619 V 397 3689 a Fo(\\n)p 1047 3719
V 603 w Fl(A)t(S)t(C)t(I)t(I)24 b Ft(Linefeed)19 b(\(LF\))p
3254 3719 V 397 3789 a Fo(\\N{)p Fq(name)p Fo(})p 1047
3819 V 320 w Ft(Character)h(named)f Fq(name)g Ft(in)i(the)f(Unicode)f
(database)h(\(Unicode)e(only\))p 3254 3819 V 397 3888
a Fo(\\r)p 1047 3918 V 603 w Fl(A)t(S)t(C)t(I)t(I)24
b Ft(Carriage)19 b(Return)h(\(CR\))p 3254 3918 V 397
3988 a Fo(\\t)p 1047 4018 V 603 w Fl(A)t(S)t(C)t(I)t(I)k
Ft(Horizontal)19 b(T)-7 b(ab)20 b(\(T)-8 b(AB\))p 3254
4018 V 397 4088 a Fo(\\u)p Fq(xxxx)p 1047 4117 V 453
w Ft(Character)20 b(with)g(16-bit)f(he)o(x)h(v)n(alue)f
Fq(xxxx)h Ft(\(Unicode)f(only\))p 3254 4117 V 514 w(\(1\))397
4187 y Fo(\\U)p Fq(xxxxxxxx)p 1047 4217 V 305 w Ft(Character)h(with)g
(32-bit)f(he)o(x)h(v)n(alue)f Fq(xxxxxxxx)h Ft(\(Unicode)f(only\))p
3254 4217 V 366 w(\(2\))397 4287 y Fo(\\v)p 1047 4317
V 603 w Fl(A)t(S)t(C)t(I)t(I)24 b Ft(V)-9 b(ertical)20
b(T)-7 b(ab)20 b(\(VT\))p 3254 4317 V 397 4386 a Fo(\\)p
Fq(ooo)p 1047 4416 V 525 w Ft(Character)g(with)g(octal)g(v)n(alue)g
Fq(ooo)p 3254 4416 V 1208 w Ft(\(3,5\))397 4486 y Fo(\\x)p
Fq(hh)p 1047 4516 V 517 w Ft(Character)g(with)g(he)o(x)f(v)n(alue)h
Fq(hh)p 3254 4516 V 1293 w Ft(\(4,5\))0 4685 y(Notes:)69
4889 y(\(1\))41 b(Indi)n(vidual)18 b(code)h(units)h(which)g(form)f
(parts)h(of)g(a)h(surrogate)d(pair)i(can)g(be)g(encoded)e(using)i(this)
h(escape)f(sequence.)69 5045 y(\(2\))41 b(An)o(y)17 b(Unicode)g
(character)f(can)i(be)g(encoded)e(this)i(w)o(ay)-5 b(,)18
b(b)n(ut)g(characters)f(outside)g(the)h(Basic)h(Multilingual)e(Plane)h
(\(BMP\))g(will)208 5145 y(be)23 b(encoded)e(using)i(a)g(surrogate)e
(pair)i(if)h(Python)e(is)i(compiled)d(to)j(use)f(16-bit)f(code)h(units)
g(\(the)g(def)o(ault\).)32 b(Indi)n(vidual)21 b(code)208
5244 y(units)f(which)f(form)h(parts)g(of)g(a)g(surrogate)f(pair)g(can)h
(be)h(encoded)d(using)i(this)g(escape)g(sequence.)69
5400 y(\(3\))41 b(As)21 b(in)f(Standard)f(C,)i(up)e(to)i(three)f(octal)
g(digits)g(are)g(accepted.)p 0 5549 3901 4 v 0 5649 a
Fp(8)2836 b(Chapter)23 b(2.)52 b(Le)n(xical)23 b(analysis)p
eop end
%%Page: 9 15
TeXDict begin 9 14 bop 69 83 a Ft(\(4\))41 b(Unlik)o(e)19
b(in)i(Standard)e(C,)i(e)o(xactly)e(tw)o(o)h(he)o(x)g(digits)g(are)g
(required.)69 249 y(\(5\))41 b(In)24 b(a)h(string)f(literal,)h(he)o
(xadecimal)e(and)g(octal)i(escapes)f(denote)g(the)g(byte)g(with)h(the)f
(gi)n(v)o(en)f(v)n(alue;)j(it)f(is)h(not)e(necessary)f(that)208
349 y(the)h(byte)h(encodes)f(a)h(character)f(in)h(the)g(source)f
(character)g(set.)40 b(In)24 b(a)i(Unicode)d(literal,)j(these)g
(escapes)f(denote)e(a)j(Unicode)208 448 y(character)18
b(with)j(the)f(gi)n(v)o(en)f(v)n(alue.)0 678 y(Unlik)o(e)h(Standard)e
(C,)j(all)g(unrecognized)c(escape)i(sequences)h(are)f(left)i(in)f(the)g
(string)g(unchanged,)d(i.e.,)i Fq(the)h(bac)n(kslash)g(is)h(left)f(in)h
(the)0 778 y(string)p Ft(.)k(\(This)18 b(beha)n(vior)e(is)k(useful)d
(when)h(deb)n(ugging:)k(if)d(an)f(escape)g(sequence)f(is)i(mistyped,)f
(the)g(resulting)g(output)f(is)i(more)e(easily)0 877
y(recognized)j(as)i(brok)o(en.\))27 b(It)22 b(is)h(also)f(important)e
(to)i(note)g(that)f(the)h(escape)g(sequences)f(mark)o(ed)f(as)i
(\223\(Unicode)f(only\)\224)f(in)i(the)g(table)0 977
y(abo)o(v)o(e)d(f)o(all)h(into)g(the)g(cate)o(gory)f(of)h(unrecognized)
d(escapes)j(for)f(non-Unicode)f(string)h(literals.)0
1124 y(When)24 b(an)f(`)p Fo(r)p Ft(')h(or)f(`)p Fo(R)p
Ft(')g(pre\002x)g(is)i(present,)f(a)g(character)e(follo)n(wing)g(a)i
(backslash)f(is)i(included)d(in)i(the)g(string)f(without)g(change,)g
(and)0 1224 y Fq(all)c(bac)n(kslashes)f(ar)m(e)h(left)h(in)f(the)g
(string)p Ft(.)24 b(F)o(or)19 b(e)o(xample,)e(the)i(string)g(literal)g
Fo(r"\\n")f Ft(consists)h(of)g(tw)o(o)g(characters:)24
b(a)19 b(backslash)f(and)0 1323 y(a)k(lo)n(wercase)g(`)p
Fo(n)p Ft('.)29 b(String)22 b(quotes)f(can)h(be)f(escaped)h(with)g(a)g
(backslash,)f(b)n(ut)h(the)g(backslash)f(remains)h(in)g(the)f(string;)i
(for)e(e)o(xample,)0 1423 y Fo(r"\\"")e Ft(is)h(a)g(v)n(alid)f(string)g
(literal)g(consisting)g(of)g(tw)o(o)g(characters:)24
b(a)c(backslash)e(and)h(a)h(double)d(quote;)i Fo(r"\\")g
Ft(is)h(not)f(a)h(v)n(alid)f(string)0 1522 y(literal)28
b(\(e)n(v)o(en)e(a)i(ra)o(w)f(string)g(cannot)f(end)h(in)h(an)f(odd)g
(number)e(of)j(backslashes\).)46 b(Speci\002cally)-5
b(,)28 b Fq(a)f(r)o(aw)h(string)g(cannot)e(end)h(in)g(a)0
1622 y(single)c(bac)n(kslash)f Ft(\(since)h(the)g(backslash)g(w)o(ould)
f(escape)h(the)g(follo)n(wing)e(quote)h(character\).)32
b(Note)23 b(also)h(that)f(a)g(single)g(backslash)0 1722
y(follo)n(wed)c(by)h(a)g(ne)n(wline)g(is)h(interpreted)d(as)j(those)f
(tw)o(o)h(characters)e(as)i(part)f(of)g(the)g(string,)f
Fq(not)h Ft(as)h(a)g(line)f(continuation.)0 1869 y(When)31
b(an)h(`)p Fo(r)p Ft(')f(or)h(`)p Fo(R)p Ft(')f(pre\002x)g(is)h(used)g
(in)f(conjunction)f(with)i(a)g(`)p Fo(u)p Ft(')f(or)g(`)p
Fo(U)p Ft(')g(pre\002x,)j(then)d(the)h Fo(\\uXXXX)f Ft(and)g
Fo(\\UXXXXXXXX)0 1968 y Ft(escape)g(sequences)g(are)h(processed)e
(while)i Fq(all)g(other)f(bac)n(kslashes)g(ar)m(e)h(left)g(in)g(the)g
(string)p Ft(.)59 b(F)o(or)32 b(e)o(xample,)g(the)g(string)f(literal)0
2068 y Fo(ur"\\u0062\\n")21 b Ft(consists)i(of)g(three)f(Unicode)f
(characters:)30 b(`LA)-9 b(TIN)21 b(SMALL)i(LETTER)f(B',)h(`REVERSE)g
(SOLIDUS',)f(and)0 2167 y(`LA)-9 b(TIN)22 b(SMALL)g(LETTER)g(N'.)h
(Backslashes)g(can)f(be)g(escaped)g(with)h(a)g(preceding)e(backslash;)i
(ho)n(we)n(v)o(er)m(,)d(both)i(remain)g(in)h(the)0 2267
y(string.)i(As)c(a)f(result,)g Fo(\\uXXXX)g Ft(escape)g(sequences)f
(are)h(only)g(recognized)e(when)h(there)h(are)g(an)g(odd)f(number)g(of)
h(backslashes.)0 2552 y Fk(2.4.2)100 b(Str)q(ing)30 b(liter)o(al)e
(concatenation)0 2755 y Ft(Multiple)21 b(adjacent)g(string)g(literals)h
(\(delimited)e(by)h(whitespace\),)f(possibly)h(using)g(dif)n(ferent)f
(quoting)f(con)m(v)o(entions,)g(are)i(allo)n(wed,)0 2855
y(and)f(their)g(meaning)f(is)i(the)f(same)h(as)g(their)f
(concatenation.)j(Thus,)c Fo("hello")49 b('world')19
b Ft(is)i(equi)n(v)n(alent)e(to)h Fo("helloworld")p Ft(.)0
2954 y(This)25 b(feature)f(can)h(be)g(used)g(to)g(reduce)f(the)h
(number)e(of)i(backslashes)g(needed,)f(to)h(split)h(long)e(strings)h
(con)m(v)o(eniently)d(across)j(long)0 3054 y(lines,)20
b(or)g(e)n(v)o(en)f(to)i(add)e(comments)g(to)i(parts)f(of)g(strings,)g
(for)f(e)o(xample:)236 3201 y Fi(re.compile\("[A-Za-z_]")310
b(#)45 b(letter)f(or)g(underscore)729 3292 y("[A-Za-z0-9_])1314
3305 y(*)1359 3292 y(")132 b(#)45 b(letter,)f(digit)g(or)g(underscore)
685 3383 y(\))0 3670 y Ft(Note)24 b(that)h(this)g(feature)e(is)i
(de\002ned)e(at)i(the)g(syntactical)f(le)n(v)o(el,)g(b)n(ut)h
(implemented)d(at)j(compile)e(time.)38 b(The)24 b(`+')g(operator)e
(must)j(be)0 3769 y(used)19 b(to)h(concatenate)e(string)h(e)o
(xpressions)f(at)i(run)f(time.)24 b(Also)c(note)f(that)h(literal)f
(concatenation)e(can)j(use)f(dif)n(ferent)f(quoting)g(styles)0
3869 y(for)i(each)f(component)f(\(e)n(v)o(en)h(mixing)g(ra)o(w)h
(strings)g(and)g(triple)g(quoted)e(strings\).)0 4154
y Fk(2.4.3)100 b(Numer)q(ic)29 b(liter)o(als)0 4357 y
Ft(There)19 b(are)g(four)g(types)g(of)h(numeric)e(literals:)25
b(plain)20 b(inte)o(gers,)e(long)h(inte)o(gers,)g(\003oating)g(point)f
(numbers,)g(and)h(imaginary)f(numbers.)0 4456 y(There)h(are)h(no)f
(comple)o(x)f(literals)j(\(comple)o(x)d(numbers)g(can)i(be)f(formed)f
(by)i(adding)e(a)j(real)e(number)g(and)g(an)h(imaginary)e(number\).)0
4703 y(Note)27 b(that)h(numeric)e(literals)h(do)g(not)g(include)f(a)i
(sign;)j(a)d(phrase)e(lik)o(e)i Fo(-1)f Ft(is)i(actually)d(an)h(e)o
(xpression)f(composed)g(of)h(the)g(unary)0 4803 y(operator)18
b(`)p Fo(-)p Ft(')i(and)g(the)g(literal)h Fo(1)p Ft(.)0
5088 y Fk(2.4.4)100 b(Integer)29 b(and)g(long)g(integer)g(liter)o(als)0
5290 y Ft(Inte)o(ger)19 b(and)g(long)h(inte)o(ger)f(literals)h(are)h
(described)d(by)i(the)g(follo)n(wing)f(le)o(xical)h(de\002nitions:)p
0 5549 3901 4 v 0 5649 a Fp(2.4.)52 b(Liter)o(als)3398
b(9)p eop end
%%Page: 10 16
TeXDict begin 10 15 bop 216 70 a Fo(longinteger)247 b
Ft(::=)99 b Fo(integer)49 b(\("l")g(|)h("L"\))216 169
y(integer)447 b Ft(::=)99 b Fo(decimalinteger)48 b(|)h(octinteger)f(|)i
(hexinteger)216 269 y(decimalinteger)97 b Ft(::=)i Fo(nonzerodigit)48
b(digit)2103 284 y(*)2202 269 y(|)h("0")216 369 y(octinteger)297
b Ft(::=)99 b Fo("0")50 b(octdigit+)216 468 y(hexinteger)297
b Ft(::=)99 b Fo("0")50 b(\("x")f(|)g("X"\))g(hexdigit+)216
568 y(nonzerodigit)197 b Ft(::=)99 b Fo("1"..."9")216
667 y(octdigit)397 b Ft(::=)99 b Fo("0"..."7")216 767
y(hexdigit)397 b Ft(::=)99 b Fo(digit)49 b(|)h("a"..."f")e(|)i
("A"..."F")0 909 y Ft(Although)17 b(both)i(lo)n(wer)f(case)i(`)p
Fo(l)p Ft(')e(and)h(upper)f(case)h(`)p Fo(L)p Ft(')g(are)g(allo)n(wed)f
(as)i(suf)n(\002x)f(for)f(long)h(inte)o(gers,)f(it)i(is)g(strongly)d
(recommended)f(to)0 1009 y(al)o(w)o(ays)21 b(use)f(`)p
Fo(L)p Ft(',)g(since)g(the)g(letter)h(`)p Fo(l)p Ft(')e(looks)h(too)g
(much)f(lik)o(e)i(the)f(digit)g(`)p Fo(1)p Ft('.)0 1156
y(Plain)j(inte)o(ger)e(literals)j(that)e(are)h(abo)o(v)o(e)e(the)i(lar)
o(gest)f(representable)e(plain)j(inte)o(ger)e(\(e.g.,)h(2147483647)d
(when)j(using)g(32-bit)f(arith-)0 1255 y(metic\))i(are)h(accepted)f(as)
h(if)g(the)o(y)f(were)h(long)f(inte)o(gers)f(instead.)1911
1225 y Fg(1)1980 1255 y Ft(There)h(is)h(no)g(limit)g(for)f(long)g(inte)
o(ger)f(literals)j(apart)e(from)g(what)0 1355 y(can)d(be)g(stored)g(in)
g(a)n(v)n(ailable)g(memory)-5 b(.)0 1502 y(Some)20 b(e)o(xamples)f(of)h
(plain)g(inte)o(ger)f(literals)h(\(\002rst)h(ro)n(w\))e(and)h(long)f
(inte)o(ger)h(literals)g(\(second)f(and)h(third)f(ro)n(ws\):)236
1740 y Fi(7)224 b(2147483647)1074 b(0177)236 1831 y(3L)179
b(79228162514264337593543950336L)174 b(0377L)134 b(0x100000000L)505
1923 y(79228162514264337593543950336)578 b(0xdeadbeef)0
2346 y Fk(2.4.5)100 b(Floating)29 b(point)g(liter)o(als)0
2549 y Ft(Floating)20 b(point)f(literals)i(are)f(described)f(by)h(the)g
(follo)n(wing)e(le)o(xical)i(de\002nitions:)216 2692
y Fo(floatnumber)197 b Ft(::=)100 b Fo(pointfloat)48
b(|)h(exponentfloat)216 2792 y(pointfloat)247 b Ft(::=)100
b Fo([intpart])48 b(fraction)g(|)i(intpart)e(".")216
2891 y(exponentfloat)97 b Ft(::=)j Fo(\(intpart)48 b(|)i(pointfloat\))d
(exponent)216 2991 y(intpart)397 b Ft(::=)100 b Fo(digit+)216
3091 y(fraction)347 b Ft(::=)100 b Fo(".")49 b(digit+)216
3190 y(exponent)347 b Ft(::=)100 b Fo(\("e")49 b(|)g("E"\))g(["+")g(|)h
("-"])f(digit+)0 3332 y Ft(Note)17 b(that)h(the)g(inte)o(ger)e(and)h(e)
o(xponent)e(parts)j(of)f(\003oating)g(point)f(numbers)g(can)i(look)e
(lik)o(e)i(octal)f(inte)o(gers,)g(b)n(ut)h(are)f(interpreted)f(using)0
3432 y(radix)j(10.)25 b(F)o(or)19 b(e)o(xample,)g(`)p
Fo(077e010)p Ft(')f(is)j(le)o(gal,)e(and)h(denotes)f(the)h(same)g
(number)e(as)j(`)p Fo(77e10)p Ft('.)j(The)19 b(allo)n(wed)h(range)f(of)
g(\003oating)0 3532 y(point)g(literals)i(is)g
(implementation-dependent.)f(Some)g(e)o(xamples)f(of)h(\003oating)f
(point)h(literals:)236 3770 y Fi(3.14)179 b(10.)g(.001)f(1e100)h
(3.14e-10)f(0e0)0 4056 y Ft(Note)27 b(that)h(numeric)e(literals)h(do)g
(not)g(include)f(a)i(sign;)j(a)d(phrase)e(lik)o(e)i Fo(-1)f
Ft(is)i(actually)d(an)h(e)o(xpression)f(composed)g(of)h(the)g(unary)0
4156 y(operator)18 b Fo(-)j Ft(and)f(the)g(literal)g
Fo(1)p Ft(.)0 4441 y Fk(2.4.6)100 b(Imaginar)s(y)29 b(liter)o(als)0
4644 y Ft(Imaginary)18 b(literals)j(are)f(described)f(by)h(the)g(follo)
n(wing)e(le)o(xical)i(de\002nitions:)216 4790 y Fo(imagnumber)98
b Ft(::=)h Fo(\(floatnumber)48 b(|)h(intpart\))g(\("j")g(|)g("J"\))0
4937 y Ft(An)23 b(imaginary)f(literal)h(yields)g(a)h(comple)o(x)d
(number)g(with)j(a)f(real)h(part)e(of)h(0.0.)33 b(Comple)o(x)22
b(numbers)g(are)h(represented)f(as)h(a)h(pair)f(of)0
5037 y(\003oating)c(point)h(numbers)f(and)g(ha)n(v)o(e)h(the)g(same)g
(restrictions)g(on)g(their)g(range.)k(T)-7 b(o)20 b(create)g(a)h
(comple)o(x)d(number)g(with)j(a)f(nonzero)f(real)p 0
5108 1560 4 v 90 5164 a Ff(1)120 5187 y Fl(In)h(v)o(ersions)h(of)f
(Python)h(prior)g(to)f(2.4,)g(octal)i(and)f(he)o(xadecimal)i(literals)g
(in)d(the)h(range)g(just)g(abo)o(v)o(e)g(the)g(lar)o(gest)h
(representable)h(plain)f(inte)o(ger)g(b)o(ut)e(belo)n(w)i(the)0
5266 y(lar)o(gest)16 b(unsigned)g(32-bit)g(number)f(\(on)g(a)f(machine)
i(using)f(32-bit)h(arithmetic\),)i(4294967296,)e(were)f(tak)o(en)i(as)d
(the)i(ne)o(gati)n(v)o(e)h(plain)f(inte)o(ger)g(obtained)h(by)e
(subtracting)0 5345 y(4294967296)k(from)d(their)j(unsigned)f(v)n(alue.)
p 0 5549 3901 4 v 0 5649 a Fp(10)2790 b(Chapter)23 b(2.)52
b(Le)n(xical)23 b(analysis)p eop end
%%Page: 11 17
TeXDict begin 11 16 bop 0 83 a Ft(part,)20 b(add)f(a)i(\003oating)e
(point)h(number)e(to)j(it,)f(e.g.,)g Fo(\(3+4j\))p Ft(.)k(Some)c(e)o
(xamples)f(of)h(imaginary)e(literals:)236 230 y Fi(3.14j)134
b(10.j)179 b(10j)223 b(.001j)134 b(1e100j)88 b(3.14e-10j)0
679 y Fm(2.5)121 b(Oper)o(ators)0 911 y Ft(The)20 b(follo)n(wing)e(tok)
o(ens)i(are)g(operators:)236 1058 y Fi(+)314 b(-)954
1071 y(*)f(**)1671 1058 y(/)g(//)269 b(\045)236 1150
y(<<)g(>>)g(&)313 b(|)h(\210)f(\230)236 1241 y(<)h(>)g(<=)268
b(>=)h(==)f(!=)h(<>)0 1527 y Ft(The)22 b(comparison)e(operators)g
Fo(<>)i Ft(and)g Fo(!=)g Ft(are)g(alternate)f(spellings)h(of)f(the)h
(same)g(operator)-5 b(.)29 b Fo(!=)22 b Ft(is)h(the)f(preferred)e
(spelling;)i Fo(<>)h Ft(is)0 1627 y(obsolescent.)0 1955
y Fm(2.6)121 b(Delimiters)0 2187 y Ft(The)20 b(follo)n(wing)e(tok)o
(ens)i(serv)o(e)g(as)h(delimiters)f(in)g(the)g(grammar:)236
2426 y Fi(\()314 b(\))g([)f(])h({)f(})269 b(@)236 2517
y(,)314 b(:)g(.)f(`)h(=)f(;)236 2608 y(+=)269 b(-=)954
2621 y(*)999 2608 y(=)f(/=)h(//=)223 b(\045=)236 2700
y(&=)269 b(|=)g(\210=)f(>>=)224 b(<<=)2029 2713 y(**)2119
2700 y(=)0 2986 y Ft(The)21 b(period)f(can)h(also)g(occur)f(in)h
(\003oating-point)e(and)i(imaginary)e(literals.)29 b(A)21
b(sequence)f(of)h(three)g(periods)f(has)h(a)h(special)f(meaning)0
3086 y(as)i(an)f(ellipsis)h(in)f(slices.)31 b(The)22
b(second)f(half)h(of)f(the)h(list,)i(the)e(augmented)e(assignment)h
(operators,)g(serv)o(e)g(le)o(xically)g(as)i(delimiters,)0
3185 y(b)n(ut)d(also)h(perform)d(an)i(operation.)0 3332
y(The)k(follo)n(wing)f(printing)i Fl(A)t(S)t(C)t(I)t(I)k
Ft(characters)23 b(ha)n(v)o(e)h(special)h(meaning)e(as)j(part)e(of)g
(other)g(tok)o(ens)g(or)h(are)f(otherwise)g(signi\002cant)g(to)0
3432 y(the)c(le)o(xical)g(analyzer:)236 3670 y Fi(')314
b(")g(#)f(\\)0 3956 y Ft(The)19 b(follo)n(wing)e(printing)i
Fl(A)t(S)t(C)t(I)t(I)j Ft(characters)c(are)h(not)g(used)f(in)h(Python.)
k(Their)c(occurrence)d(outside)i(string)h(literals)g(and)g(comments)0
4056 y(is)i(an)f(unconditional)e(error:)236 4294 y Fi($)314
b(?)p 0 5549 3901 4 v 0 5649 a Fp(2.5.)52 b(Oper)o(ators)3249
b(11)p eop end
%%Page: 12 18
TeXDict begin 12 17 bop 0 5549 3901 4 v 0 5649 a Fp(12)p
eop end
%%Page: 13 19
TeXDict begin 13 18 bop 0 83 3901 9 v 3503 230 a Fp(CHAPTER)3495
427 y Fn(THREE)p 0 515 V 2844 978 a Fz(Data)58 b(model)0
1506 y Fm(3.1)121 b(Objects)n(,)34 b(v)m(alues)f(and)i(types)0
1739 y Fq(Objects)30 b Ft(are)g(Python')-5 b(s)30 b(abstraction)f(for)g
(data.)55 b(All)31 b(data)f(in)g(a)h(Python)e(program)e(is)32
b(represented)c(by)i(objects)g(or)f(by)h(relations)0
1839 y(between)22 b(objects.)32 b(\(In)23 b(a)g(sense,)g(and)g(in)f
(conformance)e(to)j(V)-11 b(on)23 b(Neumann')-5 b(s)21
b(model)h(of)h(a)g(\223stored)f(program)f(computer)m(,)-6
b(\224)21 b(code)h(is)0 1939 y(also)f(represented)d(by)i(objects.\))0
2085 y(Ev)o(ery)26 b(object)i(has)g(an)f(identity)-5
b(,)28 b(a)h(type)e(and)g(a)h(v)n(alue.)47 b(An)28 b(object')-5
b(s)28 b Fq(identity)f Ft(ne)n(v)o(er)f(changes)h(once)g(it)i(has)f
(been)f(created;)j(you)0 2185 y(may)21 b(think)g(of)g(it)h(as)h(the)e
(object')-5 b(s)22 b(address)f(in)g(memory)-5 b(.)27
b(The)22 b(`)p Fo(is)p Ft(')f(operator)e(compares)i(the)g(identity)g
(of)g(tw)o(o)h(objects;)g(the)g Fo(id\(\))0 2285 y Ft(function)j
(returns)g(an)i(inte)o(ger)e(representing)f(its)k(identity)d
(\(currently)g(implemented)f(as)k(its)f(address\).)43
b(An)26 b(object')-5 b(s)27 b Fq(type)f Ft(is)h(also)0
2384 y(unchangeable.)481 2354 y Fg(1)536 2384 y Ft(An)19
b(object')-5 b(s)18 b(type)h(determines)e(the)i(operations)e(that)i
(the)g(object)g(supports)e(\(e.g.,)h(\223does)h(it)g(ha)n(v)o(e)g(a)g
(length?\224\))k(and)0 2484 y(also)h(de\002nes)g(the)g(possible)g(v)n
(alues)f(for)h(objects)f(of)h(that)g(type.)36 b(The)24
b Fo(type\(\))f Ft(function)f(returns)h(an)h(object')-5
b(s)24 b(type)g(\(which)f(is)i(an)0 2584 y(object)c(itself\).)27
b(The)21 b Fq(value)g Ft(of)f(some)h(objects)g(can)g(change.)26
b(Objects)c(whose)e(v)n(alue)h(can)g(change)e(are)i(said)h(to)f(be)g
Fq(mutable)p Ft(;)g(objects)0 2683 y(whose)e(v)n(alue)f(is)i
(unchangeable)c(once)i(the)o(y)h(are)g(created)f(are)h(called)g
Fq(immutable)p Ft(.)k(\(The)c(v)n(alue)f(of)h(an)g(immutable)f
(container)f(object)0 2783 y(that)23 b(contains)f(a)h(reference)e(to)i
(a)g(mutable)f(object)g(can)h(change)e(when)i(the)f(latter')-5
b(s)24 b(v)n(alue)e(is)h(changed;)g(ho)n(we)n(v)o(er)e(the)h(container)
g(is)0 2882 y(still)k(considered)d(immutable,)i(because)f(the)h
(collection)f(of)h(objects)f(it)i(contains)e(cannot)g(be)h(changed.)37
b(So,)26 b(immutability)e(is)i(not)0 2982 y(strictly)20
b(the)g(same)g(as)h(ha)n(ving)e(an)g(unchangeable)e(v)n(alue,)i(it)i
(is)g(more)e(subtle.\))24 b(An)c(object')-5 b(s)20 b(mutability)f(is)i
(determined)d(by)h(its)i(type;)0 3082 y(for)f(instance,)f(numbers,)g
(strings)h(and)f(tuples)h(are)h(immutable,)d(while)i(dictionaries)g
(and)f(lists)j(are)e(mutable.)0 3229 y(Objects)k(are)f(ne)n(v)o(er)g(e)
o(xplicitly)f(destro)o(yed;)i(ho)n(we)n(v)o(er)m(,)e(when)h(the)o(y)g
(become)f(unreachable)g(the)o(y)g(may)i(be)f(garbage-collected.)32
b(An)0 3328 y(implementation)26 b(is)j(allo)n(wed)e(to)h(postpone)e
(garbage)g(collection)h(or)h(omit)g(it)g(altogether)f(\227)h(it)h(is)g
(a)f(matter)g(of)g(implementation)0 3428 y(quality)e(ho)n(w)g(garbage)f
(collection)h(is)i(implemented,)e(as)i(long)e(as)h(no)f(objects)h(are)g
(collected)f(that)h(are)g(still)h(reachable.)43 b(\(Imple-)0
3527 y(mentation)26 b(note:)40 b(the)28 b(current)f(implementation)e
(uses)k(a)f(reference-counting)23 b(scheme)28 b(with)g(\(optional\))e
(delayed)g(detection)h(of)0 3627 y(c)o(yclically)c(link)o(ed)h
(garbage,)f(which)h(collects)g(most)g(objects)g(as)h(soon)f(as)h(the)o
(y)e(become)g(unreachable,)g(b)n(ut)h(is)h(not)f(guaranteed)e(to)0
3727 y(collect)j(garbage)e(containing)g(circular)i(references.)38
b(See)26 b(the)f Fq(Python)f(Libr)o(ary)h(Refer)m(ence)f
Ft(for)h(information)e(on)h(controlling)g(the)0 3826
y(collection)19 b(of)h(c)o(yclic)g(garbage.\))0 3973
y(Note)j(that)g(the)g(use)g(of)f(the)h(implementation')-5
b(s)21 b(tracing)h(or)h(deb)n(ugging)d(f)o(acilities)j(may)g(k)o(eep)f
(objects)h(ali)n(v)o(e)f(that)h(w)o(ould)f(normally)0
4073 y(be)e(collectable.)k(Also)d(note)f(that)g(catching)f(an)h(e)o
(xception)e(with)j(a)f(`)p Fo(try)p Ft(...)p Fo(except)p
Ft(')e(statement)i(may)g(k)o(eep)f(objects)h(ali)n(v)o(e.)0
4220 y(Some)27 b(objects)g(contain)f(references)g(to)i(\223e)o
(xternal\224)e(resources)g(such)h(as)h(open)e(\002les)j(or)e(windo)n
(ws.)45 b(It)28 b(is)g(understood)d(that)i(these)0 4319
y(resources)f(are)i(freed)e(when)h(the)g(object)g(is)i
(garbage-collected,)c(b)n(ut)i(since)h(garbage)d(collection)h(is)j(not)
e(guaranteed)e(to)i(happen,)0 4419 y(such)21 b(objects)h(also)f(pro)o
(vide)f(an)h(e)o(xplicit)g(w)o(ay)h(to)f(release)h(the)g(e)o(xternal)e
(resource,)g(usually)h(a)h Fo(close\(\))f Ft(method.)27
b(Programs)21 b(are)0 4519 y(strongly)h(recommended)e(to)j(e)o
(xplicitly)g(close)g(such)g(objects.)34 b(The)22 b(`)p
Fo(try)p Ft(...)p Fo(finally)p Ft(')f(statement)i(pro)o(vides)e(a)j
(con)m(v)o(enient)d(w)o(ay)0 4618 y(to)f(do)g(this.)0
4765 y(Some)h(objects)h(contain)e(references)h(to)g(other)g(objects;)h
(these)g(are)g(called)f Fq(container)o(s)p Ft(.)29 b(Examples)20
b(of)i(containers)e(are)i(tuples,)f(lists)0 4865 y(and)27
b(dictionaries.)46 b(The)27 b(references)g(are)g(part)h(of)f(a)h
(container')-5 b(s)26 b(v)n(alue.)47 b(In)27 b(most)h(cases,)i(when)d
(we)h(talk)g(about)e(the)i(v)n(alue)f(of)g(a)0 4964 y(container)m(,)18
b(we)h(imply)g(the)h(v)n(alues,)f(not)g(the)g(identities)h(of)f(the)g
(contained)f(objects;)h(ho)n(we)n(v)o(er)m(,)f(when)g(we)i(talk)g
(about)e(the)i(mutability)p 0 5035 1560 4 v 90 5091 a
Ff(1)120 5114 y Fl(Since)k(Python)h(2.2,)f(a)f(gradual)j(mer)o(ging)e
(of)f(types)i(and)f(classes)g(has)g(been)g(started)i(that)e(mak)o(es)g
(this)g(and)g(a)g(fe)n(w)g(other)h(assertions)g(made)f(in)f(this)h
(manual)0 5193 y(not)e(100\045)h(accurate)i(and)d(complete:)33
b(for)22 b(e)o(xample,)j(it)d Fe(is)g Fl(no)n(w)g(possible)h(in)g(some)
e(cases)i(to)f(change)i(an)e(object')l(s)i(type,)g(under)f(certain)h
(controlled)h(conditions.)0 5272 y(Until)20 b(this)f(manual)h(under)o
(goes)g(e)o(xtensi)n(v)o(e)h(re)n(vision,)g(it)e(must)g(no)n(w)g(be)g
(tak)o(en)h(as)f(authoritati)n(v)o(e)k(only)c(re)o(garding)i
(\223classic)g(classes\224,)f(that)g(are)f(still)h(the)f(def)o(ault,)j
(for)0 5351 y(compatibility)f(purposes,)c(in)g(Python)h(2.2)f(and)g
(2.3.)k(F)o(or)c(more)g(information,)h(see)g Fd(
http://www)m(.p)n
(ython.org/doc/ne)o(wstyle/)6 b Fl(.)p 0 5549 3901 4
v 3808 5649 a Fp(13)p eop end
%%Page: 14 20
TeXDict begin 14 19 bop 0 83 a Ft(of)18 b(a)g(container)m(,)f(only)g
(the)h(identities)g(of)f(the)i(immediately)d(contained)h(objects)g(are)
h(implied.)24 b(So,)18 b(if)g(an)g(immutable)f(container)g(\(lik)o(e)0
183 y(a)k(tuple\))e(contains)h(a)g(reference)f(to)h(a)h(mutable)e
(object,)g(its)i(v)n(alue)f(changes)f(if)i(that)f(mutable)f(object)h
(is)h(changed.)0 330 y(T)-7 b(ypes)24 b(af)n(fect)g(almost)g(all)h
(aspects)g(of)f(object)g(beha)n(vior)-5 b(.)36 b(Ev)o(en)24
b(the)g(importance)e(of)i(object)g(identity)g(is)h(af)n(fected)e(in)i
(some)f(sense:)0 429 y(for)f(immutable)e(types,)j(operations)e(that)h
(compute)e(ne)n(w)i(v)n(alues)g(may)g(actually)g(return)f(a)h
(reference)f(to)h(an)o(y)f(e)o(xisting)h(object)f(with)0
529 y(the)i(same)g(type)f(and)g(v)n(alue,)h(while)g(for)f(mutable)g
(objects)g(this)h(is)h(not)f(allo)n(wed.)34 b(E.g.,)24
b(after)g(`)p Fo(a)49 b(=)g(1;)h(b)g(=)f(1)p Ft(',)25
b Fo(a)f Ft(and)f Fo(b)h Ft(may)0 628 y(or)e(may)g(not)g(refer)g(to)g
(the)g(same)h(object)f(with)g(the)h(v)n(alue)e(one,)h(depending)e(on)i
(the)h(implementation,)d(b)n(ut)i(after)g(`)p Fo(c)50
b(=)f([];)h(d)f(=)0 728 y([])p Ft(',)23 b Fo(c)h Ft(and)e
Fo(d)h Ft(are)g(guaranteed)e(to)i(refer)f(to)i(tw)o(o)f(dif)n(ferent,)f
(unique,)g(ne)n(wly)g(created)g(empty)g(lists.)35 b(\(Note)23
b(that)g(`)p Fo(c)49 b(=)g(d)h(=)g([])p Ft(')0 828 y(assigns)21
b(the)f(same)g(object)g(to)g(both)g Fo(c)g Ft(and)g Fo(d)p
Ft(.\))0 1153 y Fm(3.2)121 b(The)34 b(standard)h(type)g(hier)o(arch)l
(y)0 1385 y Ft(Belo)n(w)29 b(is)h(a)f(list)h(of)e(the)h(types)f(that)h
(are)g(b)n(uilt)g(into)f(Python.)50 b(Extension)27 b(modules)h
(\(written)g(in)h(C,)g(Ja)n(v)n(a,)i(or)d(other)g(languages,)0
1485 y(depending)21 b(on)j(the)g(implementation\))e(can)h(de\002ne)h
(additional)f(types.)36 b(Future)23 b(v)o(ersions)g(of)h(Python)f(may)g
(add)h(types)g(to)g(the)g(type)0 1585 y(hierarchy)18
b(\(e.g.,)h(rational)g(numbers,)g(ef)n(\002ciently)g(stored)h(arrays)f
(of)h(inte)o(gers,)f(etc.\).)0 1732 y(Some)j(of)h(the)g(type)f
(descriptions)f(belo)n(w)h(contain)g(a)h(paragraph)d(listing)j
(`special)g(attrib)n(utes.)-6 b(')32 b(These)23 b(are)f(attrib)n(utes)h
(that)g(pro)o(vide)0 1831 y(access)e(to)f(the)g(implementation)e(and)i
(are)g(not)g(intended)f(for)g(general)g(use.)25 b(Their)20
b(de\002nition)f(may)h(change)f(in)h(the)g(future.)0
2048 y Fr(None)41 b Ft(This)18 b(type)g(has)g(a)h(single)f(v)n(alue.)24
b(There)17 b(is)i(a)g(single)f(object)f(with)i(this)f(v)n(alue.)24
b(This)18 b(object)g(is)h(accessed)f(through)e(the)i(b)n(uilt-in)208
2147 y(name)23 b Fo(None)p Ft(.)38 b(It)24 b(is)i(used)e(to)h(signify)e
(the)i(absence)e(of)h(a)h(v)n(alue)f(in)h(man)o(y)e(situations,)i
(e.g.,)g(it)g(is)g(returned)e(from)g(functions)208 2247
y(that)d(don')o(t)e(e)o(xplicitly)i(return)f(an)o(ything.)j(Its)f
(truth)f(v)n(alue)f(is)i(f)o(alse.)0 2407 y Fr(NotImplemented)41
b Ft(This)16 b(type)g(has)g(a)h(single)f(v)n(alue.)23
b(There)15 b(is)i(a)g(single)f(object)g(with)g(this)h(v)n(alue.)23
b(This)16 b(object)f(is)j(accessed)e(through)208 2507
y(the)23 b(b)n(uilt-in)g(name)f Fo(NotImplemented)p Ft(.)33
b(Numeric)22 b(methods)g(and)h(rich)g(comparison)e(methods)h(may)h
(return)f(this)i(v)n(alue)208 2607 y(if)i(the)o(y)g(do)g(not)g
(implement)f(the)h(operation)e(for)i(the)g(operands)f(pro)o(vided.)41
b(\(The)25 b(interpreter)g(will)i(then)f(try)g(the)g(re\003ected)208
2706 y(operation,)18 b(or)i(some)g(other)f(f)o(allback,)g(depending)f
(on)h(the)i(operator)-5 b(.\))23 b(Its)e(truth)e(v)n(alue)h(is)h(true.)
0 2867 y Fr(Ellipsis)43 b Ft(This)27 b(type)f(has)h(a)g(single)g(v)n
(alue.)44 b(There)26 b(is)i(a)f(single)g(object)f(with)h(this)g(v)n
(alue.)44 b(This)27 b(object)f(is)i(accessed)f(through)e(the)208
2967 y(b)n(uilt-in)e(name)h Fo(Ellipsis)p Ft(.)36 b(It)24
b(is)h(used)f(to)g(indicate)g(the)g(presence)f(of)h(the)g(`)p
Fo(...)p Ft(')37 b(syntax)23 b(in)i(a)f(slice.)38 b(Its)25
b(truth)e(v)n(alue)h(is)208 3066 y(true.)0 3227 y Fr(Numbers)42
b Ft(These)19 b(are)h(created)e(by)h(numeric)f(literals)i(and)f
(returned)f(as)i(results)g(by)f(arithmetic)g(operators)f(and)g
(arithmetic)h(b)n(uilt-in)208 3327 y(functions.)51 b(Numeric)28
b(objects)h(are)g(immutable;)k(once)c(created)f(their)h(v)n(alue)g(ne)n
(v)o(er)f(changes.)52 b(Python)28 b(numbers)g(are)h(of)208
3426 y(course)24 b(strongly)g(related)h(to)g(mathematical)f(numbers,)h
(b)n(ut)g(subject)g(to)g(the)h(limitations)f(of)g(numerical)e
(representation)g(in)208 3526 y(computers.)208 3656 y(Python)c
(distinguishes)g(between)g(inte)o(gers,)g(\003oating)h(point)f
(numbers,)g(and)g(comple)o(x)g(numbers:)208 3830 y Fr(Integers)41
b Ft(These)20 b(represent)f(elements)g(from)h(the)g(mathematical)f(set)
i(of)f(inte)o(gers)f(\(positi)n(v)o(e)g(and)h(ne)o(gati)n(v)o(e\).)390
3944 y(There)g(are)g(three)f(types)h(of)g(inte)o(gers:)390
4077 y Fr(Plain)h(integers)40 b Ft(These)19 b(represent)f(numbers)g(in)
h(the)g(range)f(-2147483648)c(through)j(2147483647.)k(\(The)d(range)g
(may)545 4177 y(be)f(lar)o(ger)e(on)h(machines)g(with)h(a)g(lar)o(ger)e
(natural)h(w)o(ord)g(size,)h(b)n(ut)g(not)f(smaller)-5
b(.\))24 b(When)16 b(the)h(result)g(of)f(an)g(operation)545
4276 y(w)o(ould)29 b(f)o(all)g(outside)g(this)g(range,)h(the)f(result)g
(is)h(normally)e(returned)f(as)j(a)f(long)f(inte)o(ger)g(\(in)h(some)g
(cases,)j(the)545 4376 y(e)o(xception)15 b Fo(OverflowError)g
Ft(is)i(raised)f(instead\).)23 b(F)o(or)17 b(the)f(purpose)f(of)h
(shift)h(and)f(mask)g(operations,)f(inte)o(gers)545 4476
y(are)20 b(assumed)f(to)h(ha)n(v)o(e)f(a)h(binary)-5
b(,)18 b(2')-5 b(s)20 b(complement)e(notation)h(using)g(32)g(or)g(more)
g(bits,)h(and)g(hiding)e(no)h(bits)i(from)545 4575 y(the)g(user)f
(\(i.e.,)f(all)i(4294967296)16 b(dif)n(ferent)i(bit)j(patterns)f
(correspond)d(to)j(dif)n(ferent)f(v)n(alues\).)390 4689
y Fr(Long)i(integers)40 b Ft(These)18 b(represent)e(numbers)g(in)i(an)g
(unlimited)e(range,)h(subject)h(to)g(a)n(v)n(ailable)f(\(virtual\))f
(memory)g(only)-5 b(.)545 4788 y(F)o(or)22 b(the)h(purpose)e(of)h
(shift)g(and)g(mask)g(operations,)f(a)i(binary)e(representation)f(is)k
(assumed,)e(and)g(ne)o(gati)n(v)o(e)e(num-)545 4888 y(bers)27
b(are)f(represented)f(in)h(a)h(v)n(ariant)f(of)g(2')-5
b(s)27 b(complement)d(which)i(gi)n(v)o(es)g(the)h(illusion)f(of)g(an)g
(in\002nite)h(string)f(of)545 4988 y(sign)21 b(bits)f(e)o(xtending)e
(to)j(the)f(left.)390 5101 y Fr(Booleans)41 b Ft(These)22
b(represent)f(the)h(truth)g(v)n(alues)f(F)o(alse)i(and)f(T)m(rue.)30
b(The)22 b(tw)o(o)g(objects)g(representing)e(the)i(v)n(alues)g(F)o
(alse)545 5201 y(and)f(T)m(rue)g(are)h(the)g(only)e(Boolean)h(objects.)
29 b(The)21 b(Boolean)g(type)g(is)i(a)f(subtype)e(of)h(plain)g(inte)o
(gers,)g(and)g(Boolean)545 5300 y(v)n(alues)27 b(beha)n(v)o(e)e(lik)o
(e)j(the)e(v)n(alues)h(0)g(and)f(1,)i(respecti)n(v)o(ely)-5
b(,)26 b(in)h(almost)g(all)h(conte)o(xts,)f(the)g(e)o(xception)e(being)
g(that)545 5400 y(when)20 b(con)m(v)o(erted)e(to)i(a)h(string,)e(the)h
(strings)h Fo("False")e Ft(or)h Fo("True")g Ft(are)g(returned,)e
(respecti)n(v)o(ely)-5 b(.)p 0 5549 3901 4 v 0 5649 a
Fp(14)2944 b(Chapter)24 b(3.)52 b(Data)23 b(model)p eop
end
%%Page: 15 21
TeXDict begin 15 20 bop 390 83 a Ft(The)26 b(rules)h(for)f(inte)o(ger)f
(representation)g(are)h(intended)f(to)i(gi)n(v)o(e)e(the)i(most)g
(meaningful)d(interpretation)g(of)i(shift)h(and)390 183
y(mask)21 b(operations)e(in)m(v)n(olving)g(ne)o(gati)n(v)o(e)g(inte)o
(gers)h(and)h(the)g(least)h(surprises)e(when)h(switching)f(between)g
(the)h(plain)g(and)390 282 y(long)15 b(inte)o(ger)f(domains.)23
b(An)o(y)15 b(operation)e(e)o(xcept)i(left)h(shift,)g(if)g(it)h(yields)
e(a)h(result)g(in)g(the)f(plain)h(inte)o(ger)e(domain)g(without)390
382 y(causing)20 b(o)o(v)o(er\003o)n(w)-5 b(,)17 b(will)k(yield)f(the)g
(same)h(result)f(in)g(the)g(long)g(inte)o(ger)f(domain)g(or)h(when)f
(using)h(mix)o(ed)f(operands.)208 515 y Fr(Floating)g(point)h(numbers)
42 b Ft(These)26 b(represent)g(machine-le)n(v)o(el)e(double)h
(precision)h(\003oating)g(point)g(numbers.)42 b(Y)-9
b(ou)26 b(are)h(at)390 614 y(the)d(merc)o(y)e(of)h(the)h(underlying)d
(machine)h(architecture)g(\(and)g(C)j(or)e(Ja)n(v)n(a)h
(implementation\))d(for)i(the)g(accepted)g(range)390
714 y(and)j(handling)e(of)i(o)o(v)o(er\003o)n(w)-5 b(.)41
b(Python)25 b(does)h(not)g(support)f(single-precision)f(\003oating)i
(point)f(numbers;)j(the)f(sa)n(vings)390 814 y(in)d(processor)e(and)g
(memory)g(usage)h(that)g(are)g(usually)g(the)g(reason)f(for)h(using)g
(these)g(is)h(dw)o(arfed)e(by)h(the)g(o)o(v)o(erhead)e(of)390
913 y(using)h(objects)f(in)h(Python,)f(so)h(there)g(is)h(no)e(reason)g
(to)h(complicate)f(the)h(language)e(with)i(tw)o(o)g(kinds)g(of)f
(\003oating)g(point)390 1013 y(numbers.)208 1146 y Fr(Complex)f
(numbers)42 b Ft(These)16 b(represent)e(comple)o(x)h(numbers)f(as)j(a)f
(pair)g(of)g(machine-le)n(v)o(el)d(double)i(precision)g(\003oating)g
(point)390 1245 y(numbers.)23 b(The)17 b(same)g(ca)n(v)o(eats)h(apply)e
(as)i(for)f(\003oating)f(point)h(numbers.)22 b(The)17
b(real)h(and)f(imaginary)e(parts)i(of)h(a)f(comple)o(x)390
1345 y(number)i Fo(z)h Ft(can)g(be)g(retrie)n(v)o(ed)f(through)f(the)i
(read-only)e(attrib)n(utes)i Fo(z.real)g Ft(and)f Fo(z.imag)p
Ft(.)0 1528 y Fr(Sequences)42 b Ft(These)17 b(represent)f(\002nite)h
(ordered)e(sets)j(inde)o(x)o(ed)d(by)i(non-ne)o(gati)n(v)o(e)c
(numbers.)22 b(The)17 b(b)n(uilt-in)f(function)g Fo(len\(\))g
Ft(returns)208 1627 y(the)k(number)e(of)h(items)i(of)e(a)i(sequence.)i
(When)d(the)g(length)f(of)h(a)g(sequence)f(is)i Fq(n)p
Ft(,)f(the)g(inde)o(x)f(set)h(contains)g(the)f(numbers)g(0,)h(1,)208
1727 y(.)12 b(.)g(.)g(,)21 b Fq(n)p Ft(-1.)j(Item)c Fq(i)h
Ft(of)f(sequence)f Fq(a)h Ft(is)h(selected)f(by)g Fq(a)p
Fo([)p Fq(i)p Fo(])p Ft(.)208 1860 y(Sequences)25 b(also)i(support)e
(slicing:)37 b Fq(a)p Fo([)p Fq(i)p Fo(:)p Fq(j)p Fo(])26
b Ft(selects)i(all)f(items)g(with)f(inde)o(x)f Fq(k)k
Ft(such)d(that)g Fq(i)h Fo(<=)g Fq(k)h Fo(<)f Fq(j)p
Ft(.)44 b(When)26 b(used)h(as)g(an)208 1959 y(e)o(xpression,)19
b(a)j(slice)f(is)h(a)g(sequence)e(of)h(the)g(same)g(type.)27
b(This)22 b(implies)f(that)g(the)g(inde)o(x)f(set)i(is)g(renumbered)c
(so)k(that)f(it)h(starts)208 2059 y(at)e(0.)208 2192
y(Some)h(sequences)g(also)h(support)f(\223e)o(xtended)f(slicing\224)i
(with)g(a)g(third)f(\223step\224)h(parameter:)27 b Fq(a)p
Fo([)p Fq(i)p Fo(:)p Fq(j)p Fo(:)p Fq(k)q Fo(])22 b Ft(selects)h(all)f
(items)h(of)e Fq(a)208 2291 y Ft(with)f(inde)o(x)f Fq(x)i
Ft(where)e Fq(x)50 b Fo(=)g Fq(i)g Fo(+)f Fq(n)1262 2306
y Fo(*)1312 2291 y Fq(k)q Ft(,)21 b Fq(n)f Fo(>=)g(0)h
Ft(and)e Fq(i)i Fo(<=)g Fq(x)f Fo(<)h Fq(j)p Ft(.)208
2424 y(Sequences)e(are)h(distinguished)e(according)h(to)h(their)g
(mutability:)208 2607 y Fr(Immutable)g(sequences)42 b
Ft(An)17 b(object)g(of)g(an)g(immutable)e(sequence)h(type)h(cannot)f
(change)f(once)i(it)g(is)h(created.)24 b(\(If)16 b(the)h(object)390
2707 y(contains)25 b(references)f(to)i(other)f(objects,)h(these)g
(other)f(objects)g(may)h(be)f(mutable)g(and)g(may)g(be)h(changed;)g(ho)
n(we)n(v)o(er)m(,)390 2806 y(the)20 b(collection)g(of)g(objects)f
(directly)h(referenced)e(by)i(an)g(immutable)f(object)g(cannot)g
(change.\))390 2922 y(The)h(follo)n(wing)f(types)h(are)g(immutable)f
(sequences:)390 3064 y Fr(Strings)41 b Ft(The)18 b(items)g(of)f(a)h
(string)g(are)f(characters.)23 b(There)17 b(is)i(no)e(separate)g
(character)f(type;)i(a)g(character)f(is)h(represented)545
3163 y(by)j(a)h(string)e(of)h(one)f(item.)28 b(Characters)21
b(represent)e(\(at)j(least\))f(8-bit)g(bytes.)27 b(The)20
b(b)n(uilt-in)h(functions)e Fo(chr\(\))i Ft(and)545 3263
y Fo(ord\(\))e Ft(con)m(v)o(ert)f(between)g(characters)g(and)h(nonne)o
(gati)n(v)o(e)d(inte)o(gers)i(representing)f(the)i(byte)g(v)n(alues.)24
b(Bytes)c(with)545 3362 y(the)i(v)n(alues)g(0-127)e(usually)i
(represent)f(the)h(corresponding)e Fl(A)t(S)t(C)t(I)t(I)26
b Ft(v)n(alues,)21 b(b)n(ut)h(the)g(interpretation)e(of)i(v)n(alues)g
(is)545 3462 y(up)d(to)g(the)f(program.)23 b(The)18 b(string)g(data)h
(type)f(is)i(also)f(used)f(to)h(represent)f(arrays)g(of)g(bytes,)h
(e.g.,)f(to)h(hold)f(data)g(read)545 3562 y(from)i(a)g(\002le.)545
3661 y(\(On)k(systems)h(whose)e(nati)n(v)o(e)h(character)e(set)j(is)g
(not)h Fl(A)t(S)t(C)t(I)t(I)r Ft(,)g(strings)e(may)g(use)g(EBCDIC)h(in)
f(their)g(internal)f(rep-)545 3761 y(resentation,)32
b(pro)o(vided)c(the)i(functions)f Fo(chr\(\))h Ft(and)g
Fo(ord\(\))g Ft(implement)f(a)i(mapping)e(between)i Fl(A)t(S)t(C)t(I)t
(I)j Ft(and)545 3861 y(EBCDIC,)21 b(and)e(string)g(comparison)f
(preserv)o(es)h(the)i Fl(A)t(S)t(C)t(I)t(I)j Ft(order)-5
b(.)23 b(Or)d(perhaps)f(someone)f(can)i(propose)e(a)i(better)545
3960 y(rule?\))390 4076 y Fr(Unicode)41 b Ft(The)21 b(items)g(of)g(a)g
(Unicode)f(object)g(are)h(Unicode)f(code)g(units.)28
b(A)21 b(Unicode)f(code)g(unit)h(is)g(represented)f(by)g(a)545
4176 y(Unicode)d(object)h(of)g(one)f(item)i(and)e(can)h(hold)g(either)f
(a)i(16-bit)e(or)h(32-bit)f(v)n(alue)g(representing)f(a)j(Unicode)e
(ordinal)545 4276 y(\(the)28 b(maximum)f(v)n(alue)h(for)g(the)g
(ordinal)f(is)i(gi)n(v)o(en)e(in)i Fo(sys.maxunicode)p
Ft(,)f(and)g(depends)f(on)h(ho)n(w)g(Python)545 4375
y(is)h(con\002gured)d(at)i(compile)f(time\).)48 b(Surrogate)26
b(pairs)i(may)f(be)h(present)f(in)h(the)g(Unicode)f(object,)i(and)e
(will)i(be)545 4475 y(reported)20 b(as)h(tw)o(o)g(separate)g(items.)28
b(The)20 b(b)n(uilt-in)h(functions)e Fo(unichr\(\))h
Ft(and)h Fo(ord\(\))f Ft(con)m(v)o(ert)f(between)h(code)545
4575 y(units)j(and)e(nonne)o(gati)n(v)o(e)e(inte)o(gers)i(representing)
f(the)i(Unicode)f(ordinals)g(as)i(de\002ned)e(in)h(the)g(Unicode)f
(Standard)545 4674 y(3.0.)37 b(Con)m(v)o(ersion)22 b(from)h(and)h(to)h
(other)e(encodings)g(are)h(possible)g(through)e(the)i(Unicode)g(method)
e Fo(encode\(\))545 4774 y Ft(and)e(the)g(b)n(uilt-in)g(function)e
Fo(unicode\(\))p Ft(.)390 4890 y Fr(T)-8 b(uples)43 b
Ft(The)28 b(items)h(of)g(a)g(tuple)f(are)g(arbitrary)f(Python)h
(objects.)50 b(T)l(uples)28 b(of)g(tw)o(o)h(or)g(more)e(items)j(are)e
(formed)f(by)545 4990 y(comma-separated)21 b(lists)k(of)e(e)o
(xpressions.)34 b(A)24 b(tuple)f(of)g(one)g(item)g(\(a)h(`singleton'\))
d(can)j(be)f(formed)f(by)h(af)n(\002xing)545 5089 y(a)g(comma)f(to)g
(an)g(e)o(xpression)f(\(an)h(e)o(xpression)f(by)h(itself)g(does)h(not)f
(create)g(a)g(tuple,)h(since)f(parentheses)f(must)i(be)545
5189 y(usable)d(for)f(grouping)f(of)h(e)o(xpressions\).)k(An)d(empty)f
(tuple)h(can)g(be)f(formed)g(by)g(an)h(empty)f(pair)h(of)f
(parentheses.)p 0 5549 3901 4 v 0 5649 a Fp(3.2.)52 b(The)23
b(standard)g(type)g(hier)o(arch)n(y)2587 b(15)p eop end
%%Page: 16 22
TeXDict begin 16 21 bop 208 83 a Fr(Mutable)20 b(sequences)42
b Ft(Mutable)27 b(sequences)h(can)g(be)g(changed)e(after)i(the)o(y)f
(are)h(created.)48 b(The)28 b(subscription)e(and)i(slicing)390
183 y(notations)19 b(can)h(be)h(used)e(as)i(the)g(tar)o(get)e(of)h
(assignment)f(and)h Fo(del)g Ft(\(delete\))f(statements.)390
299 y(There)h(is)h(currently)d(a)j(single)f(intrinsic)g(mutable)f
(sequence)g(type:)390 440 y Fr(Lists)42 b Ft(The)21 b(items)g(of)g(a)g
(list)h(are)f(arbitrary)e(Python)h(objects.)26 b(Lists)c(are)f(formed)e
(by)h(placing)g(a)i(comma-separated)17 b(list)545 540
y(of)22 b(e)o(xpressions)e(in)h(square)g(brack)o(ets.)28
b(\(Note)21 b(that)g(there)g(are)g(no)g(special)h(cases)g(needed)e(to)h
(form)g(lists)h(of)f(length)545 639 y(0)g(or)f(1.\))390
780 y(The)g(e)o(xtension)f(module)g Fo(array)g Ft(pro)o(vides)g(an)h
(additional)f(e)o(xample)g(of)h(a)g(mutable)f(sequence)g(type.)0
963 y Fr(Set)h(types)41 b Ft(These)17 b(represent)f(unordered,)f
(\002nite)i(sets)i(of)d(unique,)g(immutable)g(objects.)24
b(As)18 b(such,)f(the)o(y)g(cannot)f(be)h(inde)o(x)o(ed)e(by)h(an)o(y)
208 1063 y(subscript.)33 b(Ho)n(we)n(v)o(er)m(,)22 b(the)o(y)h(can)g
(be)g(iterated)g(o)o(v)o(er)m(,)g(and)f(the)i(b)n(uilt-in)e(function)g
Fo(len\(\))h Ft(returns)g(the)g(number)f(of)h(items)g(in)208
1162 y(a)e(set.)26 b(Common)20 b(uses)h(for)f(sets)h(are)g(f)o(ast)g
(membership)e(testing,)h(remo)o(ving)e(duplicates)i(from)g(a)h
(sequence,)e(and)h(computing)208 1262 y(mathematical)f(operations)f
(such)i(as)h(intersection,)e(union,)g(dif)n(ference,)f(and)h(symmetric)
g(dif)n(ference.)208 1395 y(F)o(or)24 b(set)i(elements,)g(the)g(same)f
(immutability)f(rules)h(apply)f(as)i(for)f(dictionary)e(k)o(e)o(ys.)40
b(Note)25 b(that)h(numeric)e(types)h(obe)o(y)f(the)208
1494 y(normal)d(rules)j(for)e(numeric)g(comparison:)29
b(if)24 b(tw)o(o)f(numbers)f(compare)f(equal)i(\(e.g.,)g
Fo(1)g Ft(and)g Fo(1.0)p Ft(\),)g(only)f(one)h(of)g(them)g(can)208
1594 y(be)d(contained)e(in)j(a)f(set.)208 1727 y(There)f(are)h
(currently)f(tw)o(o)h(intrinsic)g(set)h(types:)208 1910
y Fr(Sets)41 b Ft(These)25 b(represent)e(a)i(mutable)f(set.)40
b(The)o(y)23 b(are)i(created)f(by)g(the)h(b)n(uilt-in)f
Fo(set\(\))h Ft(constructor)d(and)j(can)f(be)h(modi\002ed)390
2009 y(afterw)o(ards)19 b(by)h(se)n(v)o(eral)g(methods,)f(such)h(as)h
Fo(add\(\))p Ft(.)208 2142 y Fr(Fr)o(ozen)e(sets)41 b
Ft(These)17 b(represent)e(an)i(immutable)e(set.)24 b(The)o(y)16
b(are)g(created)g(by)g(the)h(b)n(uilt-in)f Fo(frozenset\(\))f
Ft(constructor)-5 b(.)22 b(As)390 2242 y(a)e(frozenset)f(is)h
(immutable)e(and)h(hashable,)g(it)h(can)f(be)h(used)f(again)g(as)h(an)f
(element)g(of)h(another)e(set,)i(or)f(as)h(a)g(dictionary)390
2341 y(k)o(e)o(y)-5 b(.)0 2524 y Fr(Mappings)42 b Ft(These)20
b(represent)f(\002nite)i(sets)h(of)e(objects)g(inde)o(x)o(ed)f(by)h
(arbitrary)f(inde)o(x)g(sets.)27 b(The)20 b(subscript)g(notation)f
Fo(a[k])i Ft(selects)208 2623 y(the)h(item)h(inde)o(x)o(ed)d(by)i
Fo(k)h Ft(from)e(the)i(mapping)e Fo(a)p Ft(;)j(this)f(can)f(be)g(used)h
(in)f(e)o(xpressions)f(and)h(as)i(the)e(tar)o(get)g(of)g(assignments)g
(or)208 2723 y Fo(del)e Ft(statements.)25 b(The)20 b(b)n(uilt-in)f
(function)g Fo(len\(\))g Ft(returns)h(the)g(number)e(of)i(items)h(in)f
(a)h(mapping.)208 2856 y(There)e(is)i(currently)e(a)h(single)g
(intrinsic)g(mapping)e(type:)208 3039 y Fr(Dictionaries)40
b Ft(These)20 b(represent)g(\002nite)g(sets)i(of)e(objects)g(inde)o(x)o
(ed)f(by)h(nearly)f(arbitrary)g(v)n(alues.)26 b(The)20
b(only)f(types)i(of)f(v)n(alues)390 3138 y(not)h(acceptable)f(as)i(k)o
(e)o(ys)e(are)h(v)n(alues)g(containing)e(lists)k(or)d(dictionaries)g
(or)h(other)f(mutable)h(types)f(that)i(are)f(compared)390
3238 y(by)k(v)n(alue)f(rather)g(than)g(by)g(object)g(identity)-5
b(,)25 b(the)g(reason)f(being)g(that)g(the)h(ef)n(\002cient)g
(implementation)d(of)j(dictionaries)390 3337 y(requires)19
b(a)i(k)o(e)o(y')-5 b(s)20 b(hash)g(v)n(alue)g(to)g(remain)f(constant.)
25 b(Numeric)19 b(types)h(used)g(for)f(k)o(e)o(ys)h(obe)o(y)f(the)i
(normal)e(rules)h(for)f(nu-)390 3437 y(meric)f(comparison:)k(if)d(tw)o
(o)g(numbers)d(compare)h(equal)h(\(e.g.,)f Fo(1)i Ft(and)f
Fo(1.0)p Ft(\))g(then)g(the)o(y)f(can)h(be)h(used)f(interchangeably)390
3537 y(to)j(inde)o(x)e(the)h(same)g(dictionary)f(entry)-5
b(.)390 3653 y(Dictionaries)22 b(are)g(mutable;)g(the)o(y)f(can)h(be)g
(created)f(by)h(the)g Fo({...})g Ft(notation)e(\(see)j(section)f
(5.2.6,)e(\223Dictionary)h(Dis-)390 3753 y(plays\224\).)390
3869 y(The)f(e)o(xtension)f(modules)g Fo(dbm)p Ft(,)h
Fo(gdbm)p Ft(,)g(and)f Fo(bsddb)h Ft(pro)o(vide)e(additional)h(e)o
(xamples)g(of)h(mapping)e(types.)0 4051 y Fr(Callable)i(types)41
b Ft(These)20 b(are)g(the)g(types)g(to)h(which)e(the)i(function)d(call)
j(operation)d(\(see)i(section)g(5.3.4,)f(\223Calls\224\))i(can)f(be)g
(applied:)208 4234 y Fr(User)m(-de\002ned)g(functions)41
b Ft(A)34 b(user)n(-de\002ned)d(function)g(object)i(is)g(created)g(by)f
(a)i(function)d(de\002nition)h(\(see)h(section)f(7.6,)390
4334 y(\223Function)26 b(de\002nitions\224\).)43 b(It)27
b(should)f(be)h(called)f(with)h(an)g(ar)o(gument)d(list)k(containing)d
(the)i(same)g(number)e(of)h(items)390 4433 y(as)21 b(the)f(function')-5
b(s)19 b(formal)g(parameter)g(list.)390 4550 y(Special)h(attrib)n
(utes:)p 0 5549 3901 4 v 0 5649 a Fp(16)2944 b(Chapter)24
b(3.)52 b(Data)23 b(model)p eop end
%%Page: 17 23
TeXDict begin 17 22 bop 440 70 a Fr(Attrib)n(ute)416
b(Meaning)p 390 103 6100 4 v 440 173 a Fo(func_doc)347
b Ft(The)20 b(function')-5 b(s)19 b(documentation)e(string,)j(or)g
Fo(None)g Ft(if)g(una)n(v)n(ailable)2897 b(Writable)440
272 y Fo(__doc__)397 b Ft(Another)19 b(w)o(ay)h(of)g(spelling)g
Fo(func_doc)3682 b Ft(Writable)440 372 y Fo(func_name)297
b Ft(The)20 b(function')-5 b(s)19 b(name)4223 b(Writable)440
472 y Fo(__name__)347 b Ft(Another)19 b(w)o(ay)h(of)g(spelling)g
Fo(func_name)3632 b Ft(Writable)440 571 y Fo(__module__)247
b Ft(The)20 b(name)g(of)g(the)g(module)f(the)h(function)e(w)o(as)j
(de\002ned)e(in,)i(or)e Fo(None)h Ft(if)h(una)n(v)n(ailable.)2351
b(Writable)440 671 y Fo(func_defaults)97 b Ft(A)21 b(tuple)f
(containing)e(def)o(ault)h(ar)o(gument)f(v)n(alues)i(for)g(those)g(ar)o
(guments)e(that)i(ha)n(v)o(e)g(def)o(aults,)f(or)h Fo(None)g
Ft(if)h(no)e(ar)o(guments)f(ha)n(v)o(e)i(a)h(def)o(ault)e(v)n(alue)640
b(Writable)440 770 y Fo(func_code)297 b Ft(The)20 b(code)g(object)f
(representing)f(the)j(compiled)d(function)h(body)-5 b(.)2991
b(Writable)440 870 y Fo(func_globals)147 b Ft(A)21 b(reference)d(to)j
(the)f(dictionary)e(that)j(holds)e(the)i(function')-5
b(s)18 b(global)i(v)n(ariables)f(\227)i(the)f(global)f(namespace)g(of)h
(the)g(module)f(in)i(which)e(the)h(function)f(w)o(as)i(de\002ned.)98
b(Read-only)440 970 y Fo(func_dict)297 b Ft(The)20 b(namespace)f
(supporting)f(arbitrary)h(function)f(attrib)n(utes.)3063
b(Writable)440 1069 y Fo(func_closure)147 b(None)20 b
Ft(or)g(a)h(tuple)f(of)f(cells)i(that)g(contain)e(bindings)g(for)g(the)
h(function')-5 b(s)19 b(free)h(v)n(ariables.)2310 b(Read-only)390
1231 y(Most)21 b(of)f(the)g(attrib)n(utes)g(labelled)f
(\223Writable\224)h(check)g(the)g(type)g(of)g(the)g(assigned)g(v)n
(alue.)390 1347 y(Changed)f(in)h(v)o(ersion)f(2.4:)h
Fo(func_name)f Ft(is)i(no)n(w)f(writable.)390 1463 y(Function)j
(objects)i(also)g(support)e(getting)g(and)h(setting)h(arbitrary)e
(attrib)n(utes,)i(which)f(can)g(be)h(used,)g(for)e(e)o(xample,)h(to)390
1563 y(attach)19 b(metadata)f(to)h(functions.)k(Re)o(gular)18
b(attrib)n(ute)h(dot-notation)d(is)k(used)f(to)g(get)f(and)h(set)h
(such)e(attrib)n(utes.)25 b Fq(Note)19 b(that)390 1662
y(the)e(curr)m(ent)g(implementation)e(only)h(supports)h(function)e
(attrib)n(utes)j(on)e(user)n(-de\002ned)f(functions.)23
b(Function)15 b(attrib)n(utes)390 1762 y(on)20 b(b)n(uilt-in)g
(functions)f(may)h(be)g(supported)f(in)h(the)g(futur)m(e)o(.)390
1878 y Ft(Additional)f(information)e(about)i(a)i(function')-5
b(s)18 b(de\002nition)h(can)h(be)g(retrie)n(v)o(ed)e(from)h(its)i(code)
e(object;)h(see)h(the)f(descrip-)390 1978 y(tion)g(of)g(internal)f
(types)h(belo)n(w)-5 b(.)208 2111 y Fr(User)m(-de\002ned)20
b(methods)42 b Ft(A)29 b(user)n(-de\002ned)f(method)g(object)h
(combines)f(a)i(class,)i(a)e(class)g(instance)f(\(or)g
Fo(None)p Ft(\))g(and)f(an)o(y)390 2210 y(callable)20
b(object)g(\(normally)e(a)j(user)n(-de\002ned)d(function\).)390
2326 y(Special)f(read-only)d(attrib)n(utes:)23 b Fo(im_self)16
b Ft(is)h(the)f(class)i(instance)e(object,)g Fo(im_func)g
Ft(is)h(the)g(function)e(object;)i Fo(im_-)390 2426 y(class)25
b Ft(is)h(the)f(class)h(of)e Fo(im_self)h Ft(for)f(bound)f(methods)h
(or)g(the)h(class)h(that)f(ask)o(ed)g(for)g(the)f(method)g(for)g
(unbound)390 2526 y(methods;)i Fo(__doc__)e Ft(is)h(the)g(method')-5
b(s)24 b(documentation)d(\(same)k(as)g Fo(im_func.__doc__)p
Ft(\);)f Fo(__name__)g Ft(is)i(the)390 2625 y(method)g(name)g(\(same)h
(as)g Fo(im_func.__name__)p Ft(\);)h Fo(__module__)e
Ft(is)i(the)f(name)f(of)g(the)h(module)f(the)h(method)390
2725 y(w)o(as)22 b(de\002ned)f(in,)g(or)g Fo(None)g Ft(if)h(una)n(v)n
(ailable.)55 b(Changed)20 b(in)i(v)o(ersion)e(2.2:)g
Fo(im_self)h Ft(used)g(to)g(refer)g(to)g(the)g(class)h(that)390
2825 y(de\002ned)d(the)i(method.)390 2941 y(Methods)16
b(also)h(support)e(accessing)h(\(b)n(ut)g(not)g(setting\))g(the)h
(arbitrary)e(function)g(attrib)n(utes)h(on)g(the)h(underlying)c
(function)390 3040 y(object.)390 3157 y(User)n(-de\002ned)21
b(method)g(objects)i(may)f(be)g(created)g(when)g(getting)f(an)i(attrib)
n(ute)f(of)g(a)h(class)g(\(perhaps)e(via)i(an)f(instance)390
3256 y(of)e(that)h(class\),)g(if)f(that)h(attrib)n(ute)f(is)h(a)g(user)
n(-de\002ned)d(function)h(object,)h(an)g(unbound)e(user)n(-de\002ned)g
(method)h(object,)h(or)390 3356 y(a)26 b(class)h(method)d(object.)41
b(When)25 b(the)h(attrib)n(ute)f(is)i(a)f(user)n(-de\002ned)e(method)g
(object,)i(a)g(ne)n(w)f(method)g(object)g(is)h(only)390
3456 y(created)20 b(if)h(the)f(class)i(from)d(which)h(it)h(is)h(being)d
(retrie)n(v)o(ed)g(is)j(the)e(same)h(as,)g(or)f(a)h(deri)n(v)o(ed)e
(class)i(of,)f(the)h(class)g(stored)f(in)390 3555 y(the)g(original)f
(method)g(object;)h(otherwise,)f(the)i(original)e(method)f(object)i(is)
h(used)f(as)h(it)g(is.)390 3671 y(When)27 b(a)g(user)n(-de\002ned)e
(method)g(object)i(is)g(created)f(by)h(retrie)n(ving)e(a)i(user)n
(-de\002ned)e(function)g(object)h(from)g(a)h(class,)390
3771 y(its)i Fo(im_self)f Ft(attrib)n(ute)g(is)h Fo(None)f
Ft(and)g(the)g(method)f(object)h(is)h(said)g(to)f(be)g(unbound.)46
b(When)29 b(one)e(is)i(created)f(by)390 3871 y(retrie)n(ving)19
b(a)h(user)n(-de\002ned)e(function)h(object)g(from)g(a)i(class)g(via)f
(one)g(of)f(its)j(instances,)d(its)i Fo(im_self)f Ft(attrib)n(ute)g(is)
h(the)390 3970 y(instance,)e(and)g(the)h(method)e(object)g(is)j(said)f
(to)f(be)h(bound.)i(In)d(either)h(case,)f(the)h(ne)n(w)f(method')-5
b(s)18 b Fo(im_class)h Ft(attrib)n(ute)390 4070 y(is)i(the)f(class)h
(from)e(which)h(the)g(retrie)n(v)n(al)f(tak)o(es)h(place,)g(and)f(its)i
Fo(im_func)f Ft(attrib)n(ute)f(is)i(the)f(original)f(function)f
(object.)390 4286 y(When)g(a)g(user)n(-de\002ned)e(method)g(object)h
(is)i(created)e(by)g(retrie)n(ving)f(another)h(method)f(object)h(from)g
(a)h(class)h(or)e(instance,)390 4385 y(the)22 b(beha)n(viour)e(is)j
(the)e(same)h(as)h(for)e(a)h(function)e(object,)i(e)o(xcept)f(that)h
(the)f Fo(im_func)h Ft(attrib)n(ute)f(of)g(the)h(ne)n(w)g(instance)390
4485 y(is)f(not)f(the)g(original)f(method)g(object)h(b)n(ut)g(its)h
Fo(im_func)f Ft(attrib)n(ute.)390 4601 y(When)g(a)g(user)n(-de\002ned)e
(method)g(object)h(is)i(created)d(by)i(retrie)n(ving)e(a)i(class)g
(method)e(object)i(from)e(a)i(class)h(or)e(instance,)390
4701 y(its)h Fo(im_self)e Ft(attrib)n(ute)g(is)i(the)f(class)g(itself)h
(\(the)e(same)h(as)g(the)g Fo(im_class)f Ft(attrib)n(ute\),)g(and)g
(its)i Fo(im_func)e Ft(attrib)n(ute)390 4800 y(is)j(the)g(function)d
(object)i(underlying)d(the)j(class)i(method.)390 4917
y(When)17 b(an)f(unbound)e(user)n(-de\002ned)h(method)h(object)g(is)i
(called,)f(the)f(underlying)e(function)h(\()p Fo(im_func)p
Ft(\))h(is)h(called,)g(with)390 5016 y(the)k(restriction)g(that)g(the)g
(\002rst)h(ar)o(gument)d(must)i(be)g(an)g(instance)g(of)g(the)g(proper)
e(class)k(\()p Fo(im_class)p Ft(\))c(or)i(of)g(a)g(deri)n(v)o(ed)390
5116 y(class)g(thereof.)390 5232 y(When)15 b(a)h(bound)e(user)n
(-de\002ned)f(method)h(object)h(is)i(called,)f(the)f(underlying)e
(function)g(\()p Fo(im_func)p Ft(\))h(is)j(called,)e(inserting)390
5332 y(the)20 b(class)h(instance)e(\()p Fo(im_self)p
Ft(\))f(in)i(front)f(of)g(the)h(ar)o(gument)d(list.)26
b(F)o(or)19 b(instance,)h(when)f Fo(C)h Ft(is)g(a)g(class)h(which)e
(contains)p 0 5549 3901 4 v 0 5649 a Fp(3.2.)52 b(The)23
b(standard)g(type)g(hier)o(arch)n(y)2587 b(17)p eop end
%%Page: 18 24
TeXDict begin 18 23 bop 390 83 a Ft(a)18 b(de\002nition)f(for)g(a)h
(function)e Fo(f\(\))p Ft(,)i(and)f Fo(x)h Ft(is)h(an)e(instance)h(of)f
Fo(C)p Ft(,)h(calling)f Fo(x.f\(1\))g Ft(is)i(equi)n(v)n(alent)d(to)i
(calling)f Fo(C.f\(x,)390 183 y(1\))p Ft(.)390 299 y(When)25
b(a)g(user)n(-de\002ned)e(method)g(object)h(is)i(deri)n(v)o(ed)d(from)g
(a)i(class)h(method)d(object,)i(the)g(\223class)g(instance\224)f
(stored)g(in)390 399 y Fo(im_self)30 b Ft(will)h(actually)f(be)g(the)h
(class)g(itself,)j(so)d(that)f(calling)g(either)g Fo(x.f\(1\))g
Ft(or)g Fo(C.f\(1\))g Ft(is)i(equi)n(v)n(alent)c(to)390
498 y(calling)20 b Fo(f\(C,1\))g Ft(where)f Fo(f)i Ft(is)g(the)f
(underlying)e(function.)390 614 y(Note)g(that)h(the)f(transformation)e
(from)h(function)f(object)i(to)g(\(unbound)d(or)j(bound\))e(method)h
(object)h(happens)f(each)g(time)390 714 y(the)23 b(attrib)n(ute)g(is)h
(retrie)n(v)o(ed)e(from)g(the)h(class)h(or)f(instance.)34
b(In)22 b(some)h(cases,)i(a)e(fruitful)f(optimization)g(is)i(to)f
(assign)h(the)390 814 y(attrib)n(ute)f(to)f(a)h(local)g(v)n(ariable)f
(and)g(call)h(that)g(local)f(v)n(ariable.)32 b(Also)23
b(notice)f(that)h(this)g(transformation)d(only)i(happens)390
913 y(for)e(user)n(-de\002ned)e(functions;)h(other)g(callable)h
(objects)g(\(and)f(all)i(non-callable)d(objects\))h(are)h(retrie)n(v)o
(ed)f(without)g(trans-)390 1013 y(formation.)33 b(It)24
b(is)h(also)f(important)e(to)h(note)g(that)h(user)n(-de\002ned)e
(functions)g(which)h(are)h(attrib)n(utes)f(of)g(a)h(class)h(instance)
390 1112 y(are)20 b(not)g(con)m(v)o(erted)e(to)i(bound)e(methods;)i
(this)g Fq(only)g Ft(happens)f(when)g(the)i(function)d(is)j(an)f
(attrib)n(ute)g(of)g(the)g(class.)208 1245 y Fr(Generator)e(functions)
41 b Ft(A)27 b(function)e(or)i(method)e(which)h(uses)h(the)g
Fo(yield)f Ft(statement)h(\(see)g(section)f(6.8,)i(\223The)e
Fo(yield)390 1345 y Ft(statement\224\))21 b(is)h(called)g(a)g
Fq(g)o(ener)o(ator)e(function)p Ft(.)27 b(Such)21 b(a)h(function,)e
(when)h(called,)g(al)o(w)o(ays)h(returns)f(an)g(iterator)g(object)390
1445 y(which)j(can)f(be)h(used)g(to)f(e)o(x)o(ecute)g(the)h(body)e(of)i
(the)g(function:)30 b(calling)24 b(the)g(iterator')-5
b(s)23 b Fo(next\(\))h Ft(method)e(will)j(cause)390 1544
y(the)20 b(function)e(to)i(e)o(x)o(ecute)f(until)g(it)i(pro)o(vides)d
(a)i(v)n(alue)f(using)h(the)g Fo(yield)f Ft(statement.)25
b(When)19 b(the)h(function)e(e)o(x)o(ecutes)h(a)390 1644
y Fo(return)h Ft(statement)h(or)f(f)o(alls)i(of)n(f)e(the)h(end,)f(a)h
Fo(StopIteration)e Ft(e)o(xception)f(is)k(raised)f(and)f(the)h
(iterator)f(will)h(ha)n(v)o(e)390 1743 y(reached)e(the)h(end)g(of)g
(the)g(set)h(of)f(v)n(alues)g(to)g(be)g(returned.)208
1876 y Fr(Built-in)h(functions)41 b Ft(A)30 b(b)n(uilt-in)f(function)f
(object)h(is)i(a)f(wrapper)f(around)e(a)k(C)f(function.)52
b(Examples)29 b(of)h(b)n(uilt-in)f(func-)390 1976 y(tions)c(are)g
Fo(len\(\))g Ft(and)f Fo(math.sin\(\))g Ft(\()p Fo(math)g
Ft(is)i(a)f(standard)f(b)n(uilt-in)h(module\).)37 b(The)25
b(number)e(and)h(type)h(of)g(the)390 2076 y(ar)o(guments)16
b(are)i(determined)f(by)h(the)g(C)h(function.)j(Special)d(read-only)d
(attrib)n(utes:)24 b Fo(__doc__)17 b Ft(is)i(the)g(function')-5
b(s)16 b(doc-)390 2175 y(umentation)i(string,)h(or)h
Fo(None)f Ft(if)h(una)n(v)n(ailable;)f Fo(__name__)g
Ft(is)h(the)g(function')-5 b(s)19 b(name;)g Fo(__self__)g
Ft(is)h(set)h(to)f Fo(None)390 2275 y Ft(\(b)n(ut)i(see)i(the)e(ne)o
(xt)g(item\);)i Fo(__module__)d Ft(is)j(the)e(name)g(of)h(the)f(module)
f(the)i(function)e(w)o(as)i(de\002ned)f(in)h(or)f Fo(None)g
Ft(if)390 2374 y(una)n(v)n(ailable.)208 2507 y Fr(Built-in)f(methods)41
b Ft(This)20 b(is)h(really)e(a)h(dif)n(ferent)f(disguise)g(of)h(a)g(b)n
(uilt-in)f(function,)f(this)j(time)f(containing)e(an)h(object)h(passed)
390 2607 y(to)27 b(the)g(C)h(function)e(as)h(an)g(implicit)g(e)o(xtra)g
(ar)o(gument.)43 b(An)27 b(e)o(xample)e(of)i(a)g(b)n(uilt-in)g(method)e
(is)j Fq(alist)q Fo(.append\(\))p Ft(,)390 2707 y(assuming)23
b Fq(alist)i Ft(is)f(a)g(list)g(object.)34 b(In)23 b(this)h(case,)g
(the)f(special)h(read-only)d(attrib)n(ute)i Fo(__self__)f
Ft(is)i(set)g(to)g(the)f(object)390 2806 y(denoted)c(by)h
Fq(list)q Ft(.)208 2939 y Fr(Class)g(T)-6 b(ypes)42 b
Ft(Class)25 b(types,)f(or)g(\223ne)n(w-style)e(classes,)-6
b(\224)26 b(are)d(callable.)35 b(These)24 b(objects)f(normally)f(act)i
(as)h(f)o(actories)e(for)g(ne)n(w)390 3039 y(instances)g(of)g(themselv)
o(es,)f(b)n(ut)h(v)n(ariations)f(are)h(possible)g(for)f(class)i(types)f
(that)g(o)o(v)o(erride)e Fo(__new__\(\))p Ft(.)32 b(The)22
b(ar)o(gu-)390 3138 y(ments)c(of)g(the)g(call)g(are)g(passed)g(to)g
Fo(__new__\(\))e Ft(and,)i(in)g(the)g(typical)f(case,)i(to)f
Fo(__init__\(\))f Ft(to)h(initialize)g(the)g(ne)n(w)390
3238 y(instance.)208 3371 y Fr(Classic)i(Classes)42 b
Ft(Class)28 b(objects)f(are)g(described)e(belo)n(w)-5
b(.)44 b(When)27 b(a)g(class)h(object)e(is)i(called,)g(a)f(ne)n(w)f
(class)i(instance)f(\(also)390 3470 y(described)19 b(belo)n(w\))h(is)i
(created)d(and)h(returned.)k(This)d(implies)g(a)g(call)g(to)f(the)h
(class')-5 b(s)22 b Fo(__init__\(\))d Ft(method)g(if)i(it)g(has)390
3570 y(one.)j(An)o(y)17 b(ar)o(guments)g(are)h(passed)g(on)g(to)g(the)h
Fo(__init__\(\))e Ft(method.)23 b(If)18 b(there)f(is)j(no)e
Fo(__init__\(\))f Ft(method,)g(the)390 3670 y(class)k(must)g(be)f
(called)g(without)f(ar)o(guments.)208 3802 y Fr(Class)h(instances)42
b Ft(Class)29 b(instances)f(are)f(described)g(belo)n(w)-5
b(.)46 b(Class)30 b(instances)d(are)h(callable)g(only)f(when)g(the)g
(class)i(has)f(a)390 3902 y Fo(__call__\(\))19 b Ft(method;)g
Fo(x\(arguments\))g Ft(is)i(a)f(shorthand)e(for)i Fo
(x.__call__\(arguments\))p Ft(.)0 4085 y Fr(Modules)42
b Ft(Modules)23 b(are)g(imported)f(by)h(the)g Fo(import)g
Ft(statement)g(\(see)h(section)f(6.12,)g(\223The)g Fo(import)g
Ft(statement\224\).)34 b(A)24 b(module)208 4184 y(object)17
b(has)h(a)g(namespace)e(implemented)g(by)h(a)h(dictionary)e(object)h
(\(this)h(is)h(the)e(dictionary)f(referenced)g(by)h(the)h(func)p
3637 4184 25 4 v 28 w(globals)208 4284 y(attrib)n(ute)25
b(of)g(functions)e(de\002ned)i(in)g(the)h(module\).)38
b(Attrib)n(ute)25 b(references)f(are)i(translated)e(to)i(lookups)e(in)h
(this)h(dictionary)-5 b(,)208 4384 y(e.g.,)29 b Fo(m.x)f
Ft(is)h(equi)n(v)n(alent)d(to)i Fo(m.__dict__["x"])p
Ft(.)47 b(A)28 b(module)f(object)g(does)h(not)g(contain)f(the)h(code)f
(object)h(used)f(to)208 4483 y(initialize)20 b(the)g(module)f(\(since)h
(it)h(isn')o(t)f(needed)f(once)g(the)h(initialization)g(is)h(done\).)
208 4616 y(Attrib)n(ute)28 b(assignment)h(updates)f(the)i(module')-5
b(s)28 b(namespace)g(dictionary)-5 b(,)29 b(e.g.,)h(`)p
Fo(m.x)49 b(=)h(1)p Ft(')29 b(is)h(equi)n(v)n(alent)e(to)h(`)p
Fo(m.__-)208 4716 y(dict__["x"])47 b(=)j(1)p Ft('.)208
4848 y(Special)20 b(read-only)e(attrib)n(ute:)24 b Fo(__dict__)c
Ft(is)h(the)f(module')-5 b(s)19 b(namespace)g(as)i(a)g(dictionary)d
(object.)208 4981 y(Prede\002ned)23 b(\(writable\))g(attrib)n(utes:)34
b Fo(__name__)24 b Ft(is)h(the)g(module')-5 b(s)24 b(name;)i
Fo(__doc__)e Ft(is)h(the)g(module')-5 b(s)24 b(documentation)208
5081 y(string,)i(or)f Fo(None)g Ft(if)g(una)n(v)n(ailable;)i
Fo(__file__)d Ft(is)i(the)g(pathname)d(of)i(the)h(\002le)g(from)e
(which)h(the)g(module)f(w)o(as)i(loaded,)f(if)208 5181
y(it)f(w)o(as)g(loaded)f(from)g(a)h(\002le.)36 b(The)23
b Fo(__file__)g Ft(attrib)n(ute)g(is)i(not)e(present)g(for)g(C)i
(modules)d(that)i(are)g(statically)g(link)o(ed)f(into)208
5280 y(the)18 b(interpreter;)g(for)g(e)o(xtension)g(modules)f(loaded)h
(dynamically)f(from)h(a)h(shared)f(library)-5 b(,)18
b(it)h(is)h(the)f(pathname)e(of)h(the)h(shared)208 5380
y(library)g(\002le.)p 0 5549 3901 4 v 0 5649 a Fp(18)2944
b(Chapter)24 b(3.)52 b(Data)23 b(model)p eop end
%%Page: 19 25
TeXDict begin 19 24 bop 0 83 a Fr(Classes)42 b Ft(Class)23
b(objects)f(are)g(created)f(by)h(class)h(de\002nitions)e(\(see)h
(section)g(7.7,)f(\223Class)j(de\002nitions\224\).)29
b(A)22 b(class)h(has)f(a)h(namespace)208 183 y(implemented)d(by)i(a)h
(dictionary)d(object.)31 b(Class)24 b(attrib)n(ute)e(references)f(are)h
(translated)g(to)h(lookups)d(in)j(this)g(dictionary)-5
b(,)20 b(e.g.,)208 282 y(`)p Fo(C.x)p Ft(')g(is)j(translated)d(to)i(`)p
Fo(C.__dict__["x"])p Ft('.)j(When)d(the)f(attrib)n(ute)g(name)g(is)h
(not)f(found)f(there,)h(the)g(attrib)n(ute)g(search)208
382 y(continues)f(in)i(the)g(base)g(classes.)32 b(The)21
b(search)h(is)h(depth-\002rst,)e(left-to-right)f(in)i(the)g(order)e(of)
i(occurrence)e(in)i(the)g(base)g(class)208 482 y(list.)208
614 y(When)27 b(a)h(class)h(attrib)n(ute)e(reference)f(\(for)h(class)i
Fo(C)p Ft(,)f(say\))f(w)o(ould)g(yield)h(a)g(user)n(-de\002ned)e
(function)g(object)h(or)h(an)f(unbound)208 714 y(user)n(-de\002ned)c
(method)g(object)h(whose)g(associated)h(class)g(is)h(either)e
Fo(C)h Ft(or)g(one)f(of)g(its)i(base)f(classes,)h(it)g(is)f
(transformed)e(into)208 814 y(an)g(unbound)e(user)n(-de\002ned)h
(method)g(object)h(whose)g Fo(im_class)g Ft(attrib)n(ute)g(is)i
Fo(C)p Ft(.)e(When)h(it)g(w)o(ould)f(yield)g(a)h(class)h(method)208
913 y(object,)f(it)h(is)f(transformed)e(into)i(a)g(bound)f(user)n
(-de\002ned)f(method)h(object)g(whose)h Fo(im_class)f
Ft(and)g Fo(im_self)h Ft(attrib)n(utes)208 1013 y(are)f(both)g
Fo(C)p Ft(.)h(When)g(it)h(w)o(ould)e(yield)g(a)h(static)h(method)e
(object,)h(it)g(is)h(transformed)c(into)j(the)g(object)f(wrapped)f(by)i
(the)g(static)208 1112 y(method)15 b(object.)24 b(See)17
b(section)g(3.4.2)f(for)h(another)f(w)o(ay)h(in)g(which)g(attrib)n
(utes)g(retrie)n(v)o(ed)f(from)g(a)i(class)g(may)e(dif)n(fer)h(from)f
(those)208 1212 y(actually)j(contained)g(in)h(its)h Fo(__dict__)p
Ft(.)208 1345 y(Class)g(attrib)n(ute)f(assignments)g(update)f(the)h
(class')-5 b(s)21 b(dictionary)-5 b(,)18 b(ne)n(v)o(er)h(the)h
(dictionary)f(of)h(a)g(base)g(class.)208 1478 y(A)g(class)h(object)f
(can)g(be)g(called)g(\(see)h(abo)o(v)o(e\))d(to)i(yield)g(a)h(class)g
(instance)e(\(see)i(belo)n(w\).)208 1611 y(Special)26
b(attrib)n(utes:)39 b Fo(__name__)26 b Ft(is)i(the)f(class)h(name;)i
Fo(__module__)25 b Ft(is)j(the)f(module)f(name)g(in)h(which)g(the)g
(class)h(w)o(as)208 1710 y(de\002ned;)17 b Fo(__dict__)g
Ft(is)i(the)f(dictionary)e(containing)f(the)j(class')-5
b(s)19 b(namespace;)f Fo(__bases__)e Ft(is)j(a)f(tuple)g(\(possibly)e
(empty)208 1810 y(or)23 b(a)i(singleton\))e(containing)f(the)i(base)h
(classes,)h(in)e(the)g(order)f(of)h(their)g(occurrence)e(in)i(the)g
(base)h(class)g(list;)i Fo(__doc__)d Ft(is)208 1910 y(the)c(class')-5
b(s)21 b(documentation)d(string,)h(or)h(None)g(if)g(unde\002ned.)0
2076 y Fr(Class)h(instances)41 b Ft(A)25 b(class)h(instance)f(is)g
(created)f(by)h(calling)f(a)h(class)h(object)e(\(see)h(abo)o(v)o(e\).)
36 b(A)26 b(class)f(instance)g(has)g(a)g(namespace)208
2175 y(implemented)15 b(as)i(a)h(dictionary)d(which)h(is)i(the)f
(\002rst)h(place)e(in)h(which)g(attrib)n(ute)f(references)g(are)h
(searched.)22 b(When)17 b(an)g(attrib)n(ute)208 2275
y(is)27 b(not)g(found)e(there,)j(and)f(the)g(instance')-5
b(s)26 b(class)i(has)g(an)e(attrib)n(ute)h(by)f(that)i(name,)f(the)g
(search)g(continues)f(with)h(the)g(class)208 2374 y(attrib)n(utes.)i
(If)21 b(a)h(class)h(attrib)n(ute)e(is)i(found)d(that)i(is)g(a)g(user)n
(-de\002ned)e(function)g(object)h(or)h(an)f(unbound)e(user)n
(-de\002ned)h(method)208 2474 y(object)d(whose)h(associated)g(class)h
(is)h(the)e(class)h(\(call)f(it)h Fo(C)p Ft(\))g(of)f(the)g(instance)g
(for)f(which)h(the)g(attrib)n(ute)g(reference)f(w)o(as)i(initiated)208
2574 y(or)j(one)h(of)g(its)h(bases,)g(it)g(is)g(transformed)d(into)i(a)
g(bound)f(user)n(-de\002ned)f(method)h(object)g(whose)h
Fo(im_class)f Ft(attrib)n(ute)h(is)h Fo(C)208 2673 y
Ft(and)i(whose)g Fo(im_self)g Ft(attrib)n(ute)g(is)i(the)e(instance.)44
b(Static)28 b(method)d(and)h(class)i(method)d(objects)i(are)f(also)h
(transformed,)208 2773 y(as)h(if)h(the)o(y)e(had)g(been)h(retrie)n(v)o
(ed)e(from)h(class)i Fo(C)p Ft(;)f(see)h(abo)o(v)o(e)d(under)h
(\223Classes\224.)50 b(See)28 b(section)g(3.4.2)e(for)i(another)e(w)o
(ay)i(in)208 2873 y(which)c(attrib)n(utes)i(of)f(a)h(class)g(retrie)n
(v)o(ed)e(via)h(its)h(instances)g(may)f(dif)n(fer)f(from)g(the)i
(objects)f(actually)f(stored)h(in)h(the)f(class')-5 b(s)208
2972 y Fo(__dict__)p Ft(.)23 b(If)c(no)g(class)i(attrib)n(ute)e(is)h
(found,)e(and)g(the)i(object')-5 b(s)19 b(class)h(has)g(a)g
Fo(__getattr__\(\))d Ft(method,)h(that)h(is)i(called)208
3072 y(to)f(satisfy)g(the)h(lookup.)208 3205 y(Attrib)n(ute)g
(assignments)h(and)g(deletions)f(update)g(the)i(instance')-5
b(s)22 b(dictionary)-5 b(,)20 b(ne)n(v)o(er)h(a)i(class')-5
b(s)23 b(dictionary)-5 b(.)29 b(If)22 b(the)g(class)h(has)208
3304 y(a)j Fo(__setattr__\(\))e Ft(or)h Fo(__delattr__\(\))f
Ft(method,)h(this)h(is)h(called)f(instead)f(of)g(updating)f(the)i
(instance)f(dictionary)208 3404 y(directly)-5 b(.)208
3537 y(Class)26 b(instances)f(can)g(pretend)f(to)h(be)g(numbers,)g
(sequences,)g(or)g(mappings)e(if)j(the)o(y)e(ha)n(v)o(e)h(methods)f
(with)h(certain)f(special)208 3636 y(names.)g(See)d(section)f(3.4,)f
(\223Special)h(method)f(names.)-6 b(\224)208 3769 y(Special)20
b(attrib)n(utes:)25 b Fo(__dict__)19 b Ft(is)i(the)f(attrib)n(ute)g
(dictionary;)f Fo(__class__)g Ft(is)i(the)f(instance')-5
b(s)20 b(class.)0 3935 y Fr(Files)42 b Ft(A)29 b(\002le)g(object)g
(represents)f(an)h(open)f(\002le.)51 b(File)30 b(objects)e(are)h
(created)f(by)h(the)g Fo(open\(\))f Ft(b)n(uilt-in)g(function,)h(and)g
(also)g(by)208 4035 y Fo(os.popen\(\))p Ft(,)20 b Fo(os.fdopen\(\))p
Ft(,)g(and)h(the)g Fo(makefile\(\))f Ft(method)g(of)h(sock)o(et)g
(objects)h(\(and)e(perhaps)g(by)h(other)g(func-)208 4134
y(tions)16 b(or)f(methods)g(pro)o(vided)f(by)h(e)o(xtension)g
(modules\).)22 b(The)16 b(objects)f Fo(sys.stdin)p Ft(,)h
Fo(sys.stdout)e Ft(and)i Fo(sys.stderr)208 4234 y Ft(are)k(initialized)
h(to)g(\002le)g(objects)g(corresponding)c(to)k(the)g(interpreter')-5
b(s)20 b(standard)f(input,)i(output)e(and)h(error)g(streams.)27
b(See)22 b(the)208 4334 y Fq(Python)d(Libr)o(ary)h(Refer)m(ence)f
Ft(for)h(complete)f(documentation)e(of)j(\002le)h(objects.)0
4500 y Fr(Inter)o(nal)f(types)41 b Ft(A)25 b(fe)n(w)e(types)h(used)g
(internally)f(by)g(the)h(interpreter)e(are)i(e)o(xposed)e(to)j(the)f
(user)-5 b(.)36 b(Their)23 b(de\002nitions)g(may)h(change)208
4599 y(with)c(future)f(v)o(ersions)g(of)h(the)g(interpreter)m(,)e(b)n
(ut)i(the)o(y)g(are)g(mentioned)e(here)i(for)g(completeness.)208
4782 y Fr(Code)g(objects)40 b Ft(Code)25 b(objects)f(represent)g
Fq(byte-compiled)e Ft(e)o(x)o(ecutable)h(Python)g(code,)i(or)f
Fq(bytecode)p Ft(.)37 b(The)24 b(dif)n(ference)f(be-)390
4882 y(tween)h(a)g(code)f(object)h(and)f(a)h(function)f(object)g(is)i
(that)f(the)g(function)e(object)h(contains)g(an)h(e)o(xplicit)f
(reference)g(to)h(the)390 4981 y(function')-5 b(s)21
b(globals)g(\(the)h(module)e(in)i(which)f(it)i(w)o(as)g(de\002ned\),)d
(while)i(a)h(code)e(object)g(contains)g(no)h(conte)o(xt;)f(also)i(the)
390 5081 y(def)o(ault)16 b(ar)o(gument)e(v)n(alues)i(are)h(stored)f(in)
h(the)f(function)f(object,)i(not)f(in)h(the)f(code)g(object)g
(\(because)g(the)o(y)g(represent)f(v)n(al-)390 5181 y(ues)k(calculated)
f(at)h(run-time\).)j(Unlik)o(e)c(function)f(objects,)i(code)e(objects)i
(are)f(immutable)f(and)h(contain)g(no)g(references)390
5280 y(\(directly)h(or)h(indirectly\))f(to)h(mutable)f(objects.)p
0 5549 3901 4 v 0 5649 a Fp(3.2.)52 b(The)23 b(standard)g(type)g(hier)o
(arch)n(y)2587 b(19)p eop end
%%Page: 20 26
TeXDict begin 20 25 bop 390 83 a Ft(Special)24 b(read-only)d(attrib)n
(utes:)31 b Fo(co_name)23 b Ft(gi)n(v)o(es)g(the)g(function)f(name;)j
Fo(co_argcount)c Ft(is)k(the)e(number)f(of)h(posi-)390
183 y(tional)16 b(ar)o(guments)e(\(including)f(ar)o(guments)h(with)i
(def)o(ault)g(v)n(alues\);)g Fo(co_nlocals)f Ft(is)i(the)f(number)e(of)
h(local)h(v)n(ariables)390 282 y(used)23 b(by)g(the)g(function)f
(\(including)f(ar)o(guments\);)h Fo(co_varnames)g Ft(is)i(a)f(tuple)g
(containing)e(the)j(names)f(of)f(the)i(local)390 382
y(v)n(ariables)k(\(starting)g(with)g(the)h(ar)o(gument)d(names\);)32
b Fo(co_cellvars)27 b Ft(is)i(a)g(tuple)f(containing)f(the)h(names)g
(of)h(local)390 482 y(v)n(ariables)21 b(that)i(are)f(referenced)d(by)j
(nested)g(functions;)g Fo(co_freevars)e Ft(is)j(a)g(tuple)e(containing)
f(the)i(names)g(of)g(free)390 581 y(v)n(ariables;)i Fo(co_code)e
Ft(is)i(a)f(string)f(representing)f(the)i(sequence)f(of)g(bytecode)g
(instructions;)h Fo(co_consts)f Ft(is)h(a)h(tu-)390 681
y(ple)g(containing)e(the)h(literals)h(used)g(by)f(the)h(bytecode;)g
Fo(co_names)e Ft(is)j(a)f(tuple)f(containing)f(the)i(names)f(used)g(by)
h(the)390 780 y(bytecode;)18 b Fo(co_filename)g Ft(is)i(the)g
(\002lename)e(from)h(which)g(the)g(code)g(w)o(as)h(compiled;)e
Fo(co_firstlineno)f Ft(is)k(the)390 880 y(\002rst)27
b(line)f(number)e(of)h(the)h(function;)h Fo(co_lnotab)e
Ft(is)i(a)f(string)g(encoding)d(the)j(mapping)e(from)h(byte)h(code)f
(of)n(fsets)390 980 y(to)c(line)g(numbers)f(\(for)g(details)h(see)g
(the)g(source)f(code)g(of)h(the)g(interpreter\);)e Fo(co_stacksize)h
Ft(is)h(the)g(required)e(stack)390 1079 y(size)i(\(including)d(local)i
(v)n(ariables\);)f Fo(co_flags)h Ft(is)h(an)f(inte)o(ger)f(encoding)f
(a)j(number)d(of)i(\003ags)h(for)e(the)h(interpreter)-5
b(.)390 1189 y(The)16 b(follo)n(wing)e(\003ag)j(bits)f(are)g(de\002ned)
f(for)h Fo(co_flags)p Ft(:)22 b(bit)16 b Fo(0x04)g Ft(is)h(set)g(if)f
(the)h(function)d(uses)i(the)h(`)3375 1204 y Fo(*)3425
1189 y(arguments)p Ft(')390 1289 y(syntax)30 b(to)g(accept)g(an)g
(arbitrary)e(number)h(of)g(positional)h(ar)o(guments;)j(bit)d
Fo(0x08)g Ft(is)h(set)g(if)f(the)h(function)d(uses)j(the)390
1389 y(`)418 1404 y Fo(**)518 1389 y(keywords)p Ft(')20
b(syntax)h(to)h(accept)f(arbitrary)f(k)o(e)o(yw)o(ord)g(ar)o(guments;)g
(bit)i Fo(0x20)f Ft(is)i(set)f(if)g(the)g(function)e(is)j(a)f(gener)n
(-)390 1488 y(ator)-5 b(.)390 1598 y(Future)21 b(feature)g
(declarations)g(\(`)p Fo(from)48 b(__future__)g(import)h(division)p
Ft('\))20 b(also)i(use)g(bits)h(in)e Fo(co_flags)390
1698 y Ft(to)g(indicate)e(whether)h(a)g(code)g(object)g(w)o(as)h
(compiled)e(with)h(a)h(particular)e(feature)g(enabled:)24
b(bit)d Fo(0x2000)f Ft(is)h(set)g(if)g(the)390 1798 y(function)d(w)o
(as)i(compiled)e(with)i(future)e(di)n(vision)g(enabled;)h(bits)h
Fo(0x10)f Ft(and)g Fo(0x1000)g Ft(were)g(used)g(in)h(earlier)f(v)o
(ersions)390 1897 y(of)h(Python.)390 2007 y(Other)g(bits)h(in)f
Fo(co_flags)f Ft(are)h(reserv)o(ed)f(for)h(internal)f(use.)390
2118 y(If)28 b(a)g(code)g(object)f(represents)g(a)h(function,)g(the)g
(\002rst)h(item)f(in)g Fo(co_consts)f Ft(is)h(the)g(documentation)d
(string)j(of)g(the)390 2217 y(function,)18 b(or)i Fo(None)g
Ft(if)h(unde\002ned.)208 2338 y Fr(Frame)e(objects)41
b Ft(Frame)20 b(objects)g(represent)f(e)o(x)o(ecution)f(frames.)24
b(The)o(y)19 b(may)h(occur)f(in)i(traceback)d(objects)i(\(see)h(belo)n
(w\).)390 2448 y(Special)i(read-only)e(attrib)n(utes:)31
b Fo(f_back)23 b Ft(is)h(to)f(the)g(pre)n(vious)f(stack)h(frame)f(\(to)
n(w)o(ards)h(the)g(caller\),)g(or)g Fo(None)g Ft(if)g(this)390
2548 y(is)28 b(the)g(bottom)e(stack)i(frame;)i Fo(f_code)c
Ft(is)j(the)e(code)g(object)g(being)f(e)o(x)o(ecuted)f(in)j(this)g
(frame;)i Fo(f_locals)c Ft(is)j(the)390 2647 y(dictionary)e(used)g(to)i
(look)e(up)h(local)g(v)n(ariables;)j Fo(f_globals)c Ft(is)i(used)f(for)
f(global)h(v)n(ariables;)j Fo(f_builtins)c Ft(is)390
2747 y(used)20 b(for)f(b)n(uilt-in)h(\(intrinsic\))f(names;)g
Fo(f_restricted)g Ft(is)i(a)f(\003ag)g(indicating)f(whether)g(the)h
(function)e(is)j(e)o(x)o(ecuting)390 2846 y(in)26 b(restricted)g(e)o(x)
o(ecution)e(mode;)k Fo(f_lasti)d Ft(gi)n(v)o(es)g(the)h(precise)g
(instruction)f(\(this)h(is)h(an)f(inde)o(x)f(into)g(the)h(bytecode)390
2946 y(string)20 b(of)g(the)g(code)g(object\).)390 3056
y(Special)25 b(writable)g(attrib)n(utes:)35 b Fo(f_trace)p
Ft(,)26 b(if)f(not)g Fo(None)p Ft(,)h(is)g(a)g(function)d(called)i(at)h
(the)f(start)h(of)f(each)g(source)f(code)390 3156 y(line)e(\(this)g(is)
h(used)e(by)h(the)f(deb)n(ugger\);)f Fo(f_exc_type)p
Ft(,)h Fo(f_exc_value)p Ft(,)f Fo(f_exc_traceback)g Ft(represent)h(the)
390 3255 y(last)j(e)o(xception)e(raised)h(in)g(the)h(parent)e(frame)h
(pro)o(vided)d(another)i(e)o(xception)g(w)o(as)i(e)n(v)o(er)e(raised)i
(in)f(the)g(current)f(frame)390 3355 y(\(in)i(all)h(other)f(cases)h
(the)o(y)e(are)i(None\);)g Fo(f_lineno)f Ft(is)h(the)f(current)f(line)i
(number)d(of)i(the)g(frame)g(\227)h(writing)f(to)g(this)390
3455 y(from)h(within)h(a)g(trace)f(function)f(jumps)i(to)g(the)g(gi)n
(v)o(en)e(line)i(\(only)f(for)g(the)h(bottom-most)d(frame\).)41
b(A)26 b(deb)n(ugger)e(can)390 3554 y(implement)19 b(a)i(Jump)e
(command)g(\(aka)g(Set)i(Ne)o(xt)f(Statement\))f(by)h(writing)g(to)g(f)
p 2707 3554 25 4 v 30 w(lineno.)208 3675 y Fr(T)-6 b(raceback)19
b(objects)41 b Ft(T)m(raceback)26 b(objects)i(represent)f(a)h(stack)h
(trace)e(of)h(an)g(e)o(xception.)47 b(A)28 b(traceback)f(object)g(is)i
(created)390 3774 y(when)19 b(an)h(e)o(xception)e(occurs.)24
b(When)19 b(the)h(search)f(for)g(an)g(e)o(xception)f(handler)g(unwinds)
h(the)h(e)o(x)o(ecution)d(stack,)j(at)g(each)390 3874
y(unw)o(ound)f(le)n(v)o(el)h(a)i(traceback)d(object)i(is)g(inserted)g
(in)g(front)f(of)g(the)h(current)f(traceback.)25 b(When)c(an)g(e)o
(xception)e(handler)390 3974 y(is)k(entered,)f(the)g(stack)h(trace)f
(is)h(made)f(a)n(v)n(ailable)f(to)i(the)f(program.)29
b(\(See)22 b(section)g(7.4,)g(\223The)g Fo(try)g Ft(statement.)-6
b(\224\))31 b(It)23 b(is)390 4073 y(accessible)j(as)g
Fo(sys.exc_traceback)p Ft(,)d(and)i(also)h(as)g(the)f(third)g(item)g
(of)g(the)g(tuple)g(returned)f(by)h Fo(sys.exc_-)390
4173 y(info\(\))p Ft(.)f(The)c(latter)g(is)g(the)g(preferred)e(interf)o
(ace,)h(since)g(it)i(w)o(orks)e(correctly)g(when)g(the)h(program)d(is)k
(using)e(multiple)390 4273 y(threads.)24 b(When)18 b(the)h(program)d
(contains)i(no)g(suitable)h(handler)m(,)e(the)h(stack)h(trace)g(is)g
(written)g(\(nicely)e(formatted\))g(to)i(the)390 4372
y(standard)e(error)g(stream;)i(if)f(the)h(interpreter)d(is)j(interacti)
n(v)o(e,)e(it)i(is)g(also)f(made)g(a)n(v)n(ailable)g(to)g(the)g(user)g
(as)h Fo(sys.last_-)390 4472 y(traceback)p Ft(.)390 4582
y(Special)26 b(read-only)d(attrib)n(utes:)35 b Fo(tb_next)25
b Ft(is)i(the)e(ne)o(xt)g(le)n(v)o(el)g(in)h(the)f(stack)h(trace)f
(\(to)n(w)o(ards)g(the)g(frame)g(where)g(the)390 4682
y(e)o(xception)f(occurred\),)h(or)g Fo(None)g Ft(if)i(there)e(is)h(no)g
(ne)o(xt)f(le)n(v)o(el;)j Fo(tb_frame)d Ft(points)g(to)h(the)g(e)o(x)o
(ecution)d(frame)i(of)h(the)390 4781 y(current)18 b(le)n(v)o(el;)i
Fo(tb_lineno)e Ft(gi)n(v)o(es)h(the)g(line)g(number)f(where)h(the)g(e)o
(xception)e(occurred;)h Fo(tb_lasti)h Ft(indicates)g(the)390
4881 y(precise)i(instruction.)26 b(The)20 b(line)h(number)f(and)g(last)
i(instruction)d(in)j(the)f(traceback)e(may)i(dif)n(fer)e(from)h(the)h
(line)g(number)390 4981 y(of)g(its)i(frame)d(object)h(if)h(the)f(e)o
(xception)e(occurred)h(in)h(a)h Fo(try)f Ft(statement)g(with)h(no)f
(matching)f(e)o(xcept)g(clause)i(or)f(with)g(a)390 5080
y(\002nally)f(clause.)208 5201 y Fr(Slice)g(objects)41
b Ft(Slice)21 b(objects)g(are)g(used)f(to)h(represent)f(slices)h(when)g
Fq(e)n(xtended)e(slice)j(syntax)e Ft(is)i(used.)27 b(This)21
b(is)g(a)h(slice)f(using)390 5300 y(tw)o(o)f(colons,)e(or)h(multiple)g
(slices)h(or)f(ellipses)h(separated)e(by)h(commas,)g(e.g.,)f
Fo(a[i:j:step])p Ft(,)g Fo(a[i:j,)49 b(k:l])p Ft(,)19
b(or)390 5400 y Fo(a[...,)49 b(i:j])p Ft(.)25 b(The)o(y)19
b(are)h(also)g(created)g(by)g(the)g(b)n(uilt-in)f Fo(slice\(\))h
Ft(function.)p 0 5549 3901 4 v 0 5649 a Fp(20)2944 b(Chapter)24
b(3.)52 b(Data)23 b(model)p eop end
%%Page: 21 27
TeXDict begin 21 26 bop 390 83 a Ft(Special)18 b(read-only)e(attrib)n
(utes:)25 b Fo(start)17 b Ft(is)j(the)e(lo)n(wer)g(bound;)f
Fo(stop)h Ft(is)h(the)f(upper)f(bound;)g Fo(step)h Ft(is)h(the)g(step)f
(v)n(alue;)390 183 y(each)i(is)h Fo(None)f Ft(if)h(omitted.)j(These)c
(attrib)n(utes)g(can)g(ha)n(v)o(e)g(an)o(y)f(type.)390
299 y(Slice)i(objects)f(support)f(one)g(method:)390 415
y Fh(indices)p Fo(\()p Fq(self)o(,)h(length)p Fo(\))545
515 y Ft(This)30 b(method)e(tak)o(es)i(a)g(single)f(inte)o(ger)f(ar)o
(gument)f Fq(length)i Ft(and)g(computes)f(information)f(about)h(the)i
(e)o(xtended)545 614 y(slice)c(that)f(the)g(slice)h(object)f(w)o(ould)f
(describe)g(if)i(applied)e(to)h(a)g(sequence)f(of)h Fq(length)f
Ft(items.)40 b(It)25 b(returns)f(a)i(tuple)545 714 y(of)d(three)g(inte)
o(gers;)h(respecti)n(v)o(ely)e(these)h(are)g(the)g Fq(start)j
Ft(and)d Fq(stop)g Ft(indices)g(and)f(the)i Fq(step)f
Ft(or)g(stride)g(length)g(of)g(the)545 814 y(slice.)30
b(Missing)21 b(or)g(out-of-bounds)d(indices)j(are)g(handled)f(in)h(a)h
(manner)e(consistent)h(with)h(re)o(gular)e(slices.)58
b(Ne)n(w)545 913 y(in)21 b(v)o(ersion)e(2.3.)208 1046
y Fr(Static)g(method)h(objects)41 b Ft(Static)20 b(method)e(objects)h
(pro)o(vide)f(a)i(w)o(ay)f(of)h(defeating)d(the)j(transformation)d(of)i
(function)f(objects)390 1146 y(to)i(method)f(objects)h(described)e(abo)
o(v)o(e.)24 b(A)c(static)h(method)e(object)g(is)i(a)f(wrapper)f(around)
f(an)o(y)h(other)g(object,)h(usually)f(a)390 1245 y(user)n(-de\002ned)i
(method)g(object.)30 b(When)22 b(a)h(static)g(method)e(object)h(is)h
(retrie)n(v)o(ed)d(from)i(a)g(class)i(or)e(a)g(class)h(instance,)g(the)
390 1345 y(object)h(actually)g(returned)f(is)j(the)f(wrapped)e(object,)
i(which)f(is)h(not)g(subject)f(to)h(an)o(y)f(further)f(transformation.)
36 b(Static)390 1445 y(method)28 b(objects)g(are)h(not)g(themselv)o(es)
f(callable,)i(although)d(the)i(objects)g(the)o(y)f(wrap)g(usually)h
(are.)50 b(Static)30 b(method)390 1544 y(objects)20 b(are)g(created)g
(by)f(the)i(b)n(uilt-in)e Fo(staticmethod\(\))f Ft(constructor)-5
b(.)208 1677 y Fr(Class)20 b(method)h(objects)40 b Ft(A)25
b(class)h(method)d(object,)i(lik)o(e)g(a)g(static)g(method)f(object,)h
(is)g(a)g(wrapper)e(around)g(another)g(object)390 1777
y(that)28 b(alters)g(the)f(w)o(ay)h(in)g(which)f(that)g(object)g(is)i
(retrie)n(v)o(ed)d(from)g(classes)j(and)e(class)h(instances.)47
b(The)27 b(beha)n(viour)f(of)390 1876 y(class)20 b(method)e(objects)h
(upon)f(such)h(retrie)n(v)n(al)f(is)i(described)e(abo)o(v)o(e,)f(under)
h(\223User)n(-de\002ned)g(methods\224.)23 b(Class)e(method)390
1976 y(objects)f(are)g(created)g(by)f(the)i(b)n(uilt-in)e
Fo(classmethod\(\))g Ft(constructor)-5 b(.)0 2303 y Fm(3.3)121
b(Ne)n(w-style)33 b(and)i(classic)d(classes)0 2536 y
Ft(Classes)22 b(and)d(instances)i(come)e(in)h(tw)o(o)h(\003a)n(v)n
(ors:)k(old-style)20 b(or)g(classic,)h(and)e(ne)n(w-style.)0
2683 y(Up)28 b(to)h(Python)e(2.1,)j(old-style)e(classes)h(were)g(the)f
(only)g(\003a)n(v)n(our)g(a)n(v)n(ailable)g(to)g(the)h(user)-5
b(.)50 b(The)28 b(concept)f(of)h(\(old-style\))f(class)j(is)0
2783 y(unrelated)20 b(to)i(the)f(concept)g(of)g(type:)27
b(if)22 b Fq(x)g Ft(is)h(an)e(instance)h(of)f(an)g(old-style)g(class,)i
(then)e Fo(x.__class__)f Ft(designates)h(the)g(class)i(of)0
2882 y Fq(x)p Ft(,)g(b)n(ut)g Fo(type\(x\))e Ft(is)j(al)o(w)o(ays)e
Fo(<type)49 b('instance'>)p Ft(.)30 b(This)23 b(re\003ects)f(the)h(f)o
(act)f(that)h(all)g(old-style)e(instances,)i(independently)0
2982 y(of)d(their)g(class,)h(are)f(implemented)e(with)j(a)f(single)g(b)
n(uilt-in)g(type,)f(called)h Fo(instance)p Ft(.)0 3129
y(Ne)n(w-style)j(classes)i(were)e(introduced)f(in)h(Python)g(2.2)f(to)i
(unify)f(classes)h(and)f(types.)35 b(A)24 b(ne)n(w-style)f(class)h
(neither)f(more)g(nor)f(less)0 3228 y(than)e(a)g(user)n(-de\002ned)f
(type.)24 b(If)c Fq(x)h Ft(is)g(an)f(instance)g(of)g(a)h(ne)n(w-style)e
(class,)i(then)f Fo(type\(x\))f Ft(is)i(the)g(same)f(as)h
Fo(x.__class__)p Ft(.)0 3375 y(The)j(major)g(moti)n(v)n(ation)e(for)i
(introducing)e(ne)n(w-style)h(classes)j(is)f(to)f(pro)o(vide)f(a)h
(uni\002ed)g(object)g(model)f(with)i(a)f(full)h(meta-model.)0
3475 y(It)31 b(also)f(has)h(a)f(number)f(of)h(immediate)f(bene\002ts,)k
(lik)o(e)d(the)g(ability)g(to)h(subclass)f(most)h(b)n(uilt-in)e(types,)
k(or)d(the)g(introduction)e(of)0 3575 y(\224descriptors\224,)19
b(which)g(enable)h(computed)e(properties.)0 3721 y(F)o(or)25
b(compatibility)f(reasons,)h(classes)i(are)e(still)i(old-style)d(by)h
(def)o(ault.)39 b(Ne)n(w-style)25 b(classes)i(are)e(created)f(by)h
(specifying)f(another)0 3821 y(ne)n(w-style)30 b(class)i(\(i.e.)e(a)h
(type\))f(as)i(a)f(parent)f(class,)k(or)c(the)h(\224top-le)n(v)o(el)e
(type\224)h Fo(object)h Ft(if)g(no)f(other)g(parent)g(is)i(needed.)55
b(The)0 3921 y(beha)n(viour)25 b(of)h(ne)n(w-style)g(classes)i(dif)n
(fers)e(from)g(that)h(of)g(old-style)f(classes)i(in)f(a)g(number)e(of)h
(important)g(details)h(in)g(addition)e(to)0 4020 y(what)g
Fo(type)f Ft(returns.)37 b(Some)24 b(of)h(these)f(changes)g(are)g
(fundamental)f(to)h(the)h(ne)n(w)f(object)g(model,)h(lik)o(e)g(the)f(w)
o(ay)h(special)g(methods)0 4120 y(are)k(in)m(v)n(ok)o(ed.)49
b(Others)29 b(are)g(\224\002x)o(es\224)f(that)h(could)f(not)h(be)g
(implemented)e(before)g(for)h(compatibility)f(concerns,)j(lik)o(e)f
(the)g(method)0 4220 y(resolution)19 b(order)g(in)h(case)h(of)f
(multiple)f(inheritance.)0 4366 y(This)94 b(manual)f(is)i(not)f
(up-to-date)e(with)i(respect)g(to)g(ne)n(w-style)g(classes.)248
b(F)o(or)93 b(no)n(w)-5 b(,)112 b(please)94 b(see)0 4466
y Fu(
http://www)l(.p)n(ython.org/d)o(oc/n)o(e)n(wstyle/)15
b Ft(for)k(more)g(information.)0 4613 y(The)27 b(plan)g(is)i(to)e(e)n
(v)o(entually)f(drop)g(old-style)h(classes,)j(lea)n(ving)d(only)g(the)g
(semantics)h(of)f(ne)n(w-style)g(classes.)48 b(This)28
b(change)e(will)0 4713 y(probably)18 b(only)h(be)h(feasible)g(in)h
(Python)e(3.0.)24 b(ne)n(w-style)19 b(classic)j(old-style)0
5040 y Fm(3.4)121 b(Special)33 b(method)i(names)0 5273
y Ft(A)17 b(class)h(can)e(implement)f(certain)h(operations)f(that)i
(are)f(in)m(v)n(ok)o(ed)f(by)h(special)h(syntax)e(\(such)h(as)i
(arithmetic)d(operations)g(or)i(subscript-)0 5372 y(ing)h(and)h
(slicing\))f(by)g(de\002ning)g(methods)g(with)h(special)g(names.)24
b(This)19 b(is)g(Python')-5 b(s)18 b(approach)f(to)i
Fq(oper)o(ator)f(o)o(verloading)p Ft(,)f(allo)n(wing)p
0 5549 3901 4 v 0 5649 a Fp(3.3.)52 b(Ne)n(w-style)23
b(and)g(classic)g(classes)2520 b(21)p eop end
%%Page: 22 28
TeXDict begin 22 27 bop 0 83 a Ft(classes)18 b(to)g(de\002ne)e(their)h
(o)n(wn)g(beha)n(vior)f(with)h(respect)g(to)g(language)f(operators.)22
b(F)o(or)17 b(instance,)g(if)g(a)h(class)g(de\002nes)f(a)h(method)e
(named)0 183 y Fo(__getitem__\(\))p Ft(,)24 b(and)g Fo(x)i
Ft(is)g(an)e(instance)h(of)g(this)g(class,)i(then)e Fo(x[i])f
Ft(is)i(equi)n(v)n(alent)2665 153 y Fg(2)2722 183 y Ft(to)f
Fo(x.__getitem__\(i\))p Ft(.)36 b(Except)0 282 y(where)20
b(mentioned,)e(attempts)i(to)g(e)o(x)o(ecute)f(an)h(operation)e(raise)j
(an)f(e)o(xception)e(when)i(no)g(appropriate)d(method)i(is)i
(de\002ned.)0 429 y(When)26 b(implementing)e(a)i(class)i(that)e
(emulates)g(an)o(y)f(b)n(uilt-in)h(type,)g(it)h(is)g(important)e(that)h
(the)g(emulation)f(only)g(be)h(implemented)0 529 y(to)f(the)h(de)o
(gree)d(that)j(it)g(mak)o(es)f(sense)h(for)e(the)h(object)g(being)f
(modelled.)39 b(F)o(or)25 b(e)o(xample,)g(some)g(sequences)f(may)h(w)o
(ork)g(well)g(with)0 628 y(retrie)n(v)n(al)e(of)i(indi)n(vidual)d
(elements,)j(b)n(ut)g(e)o(xtracting)d(a)j(slice)g(may)f(not)h(mak)o(e)f
(sense.)38 b(\(One)24 b(e)o(xample)f(of)h(this)h(is)g(the)f
Fo(NodeList)0 728 y Ft(interf)o(ace)19 b(in)i(the)f(W3C')-5
b(s)21 b(Document)e(Object)h(Model.\))0 1013 y Fk(3.4.1)100
b(Basic)28 b(customization)0 1202 y Fh(__new__)p Fo(\()p
Fq(cls)p Fc([)p Fq(,)19 b(...)12 b Fc(])p Fo(\))208 1301
y Ft(Called)28 b(to)f(create)h(a)g(ne)n(w)f(instance)h(of)f(class)i
Fq(cls)p Ft(.)48 b Fo(__new__\(\))26 b Ft(is)j(a)f(static)g(method)f
(\(special-cased)f(so)i(you)f(need)g(not)208 1401 y(declare)22
b(it)h(as)h(such\))e(that)h(tak)o(es)g(the)g(class)h(of)f(which)f(an)h
(instance)g(w)o(as)g(requested)f(as)i(its)f(\002rst)h(ar)o(gument.)31
b(The)22 b(remaining)208 1501 y(ar)o(guments)28 b(are)j(those)f(passed)
g(to)h(the)g(object)f(constructor)e(e)o(xpression)h(\(the)h(call)h(to)g
(the)g(class\).)56 b(The)31 b(return)e(v)n(alue)h(of)208
1600 y Fo(__new__\(\))19 b Ft(should)g(be)h(the)g(ne)n(w)g(object)g
(instance)g(\(usually)f(an)h(instance)g(of)g Fq(cls)p
Ft(\).)208 1733 y(T)-7 b(ypical)23 b(implementations)g(create)h(a)g(ne)
n(w)h(instance)e(of)h(the)h(class)g(by)f(in)m(v)n(oking)e(the)i
(superclass')-5 b(s)25 b Fo(__new__\(\))e Ft(method)208
1833 y(using)e(`)p Fo(super\()p Fq(curr)m(entclass)p
Fo(,)48 b Fq(cls)p Fo(\).__new__\()p Fq(cls)p Fo([,)g(...]\))p
Ft(')31 b(with)22 b(appropriate)e(ar)o(guments)h(and)h(then)g(modify-)
208 1932 y(ing)d(the)i(ne)n(wly-created)d(instance)h(as)i(necessary)f
(before)f(returning)f(it.)208 2065 y(If)k Fo(__new__\(\))g
Ft(returns)g(an)h(instance)g(of)g Fq(cls)p Ft(,)h(then)e(the)h(ne)n(w)g
(instance')-5 b(s)23 b Fo(__init__\(\))f Ft(method)f(will)j(be)f(in)m
(v)n(ok)o(ed)e(lik)o(e)208 2165 y(`)p Fo(__init__\()p
Fq(self)12 b Fo([,)47 b(...]\))p Ft(',)29 b(where)f Fq(self)41
b Ft(is)29 b(the)f(ne)n(w)g(instance)f(and)h(the)g(remaining)e(ar)o
(guments)g(are)i(the)g(same)g(as)208 2264 y(were)20 b(passed)g(to)g
Fo(__new__\(\))p Ft(.)208 2397 y(If)k Fo(__new__\(\))g
Ft(does)g(not)h(return)e(an)i(instance)f(of)g Fq(cls)p
Ft(,)j(then)d(the)h(ne)n(w)f(instance')-5 b(s)25 b Fo(__init__\(\))e
Ft(method)h(will)h(not)g(be)208 2497 y(in)m(v)n(ok)o(ed.)208
2630 y Fo(__new__\(\))h Ft(is)j(intended)d(mainly)h(to)h(allo)n(w)f
(subclasses)h(of)g(immutable)e(types)i(\(lik)o(e)f(int,)j(str)m(,)f(or)
f(tuple\))f(to)g(customize)208 2729 y(instance)19 b(creation.)0
2876 y Fh(__init__)p Fo(\()p Fq(self)12 b Fc([)p Fq(,)19
b(...)12 b Fc(])p Fo(\))208 2976 y Ft(Called)25 b(when)g(the)g
(instance)g(is)h(created.)39 b(The)25 b(ar)o(guments)e(are)i(those)g
(passed)g(to)g(the)g(class)i(constructor)c(e)o(xpression.)38
b(If)25 b(a)208 3076 y(base)20 b(class)i(has)e(an)h Fo(__init__\(\))e
Ft(method,)g(the)h(deri)n(v)o(ed)f(class')-5 b(s)22 b
Fo(__init__\(\))d Ft(method,)g(if)i(an)o(y)-5 b(,)19
b(must)i(e)o(xplicitly)e(call)208 3175 y(it)i(to)g(ensure)g(proper)e
(initialization)h(of)h(the)g(base)g(class)h(part)f(of)g(the)g
(instance;)g(for)f(e)o(xample:)26 b(`)p Fo(BaseClass.__init_-)208
3275 y(_\()p Fq(self)12 b Fo(,)49 b([)p Fq(ar)m(gs)p
Fo(...]\))p Ft('.)24 b(As)d(a)g(special)g(constraint)e(on)h
(constructors,)e(no)i(v)n(alue)g(may)g(be)g(returned;)f(doing)g(so)i
(will)g(cause)208 3374 y(a)f Fo(TypeError)f Ft(to)i(be)f(raised)g(at)g
(runtime.)0 3521 y Fh(__del__)p Fo(\()p Fq(self)12 b
Fo(\))208 3621 y Ft(Called)k(when)g(the)h(instance)f(is)i(about)d(to)i
(be)g(destro)o(yed.)22 b(This)17 b(is)g(also)g(called)g(a)g
(destructor.)22 b(If)16 b(a)h(base)g(class)g(has)g(a)g
Fo(__del_-)208 3721 y(_\(\))24 b Ft(method,)g(the)g(deri)n(v)o(ed)e
(class')-5 b(s)26 b Fo(__del__\(\))d Ft(method,)h(if)h(an)o(y)-5
b(,)24 b(must)g(e)o(xplicitly)f(call)i(it)g(to)f(ensure)g(proper)f
(deletion)208 3820 y(of)e(the)h(base)h(class)g(part)e(of)h(the)g
(instance.)30 b(Note)22 b(that)g(it)h(is)g(possible)f(\(though)e(not)h
(recommended!\))27 b(for)22 b(the)g Fo(__del__\(\))208
3920 y Ft(method)d(to)h(postpone)f(destruction)g(of)h(the)g(instance)g
(by)g(creating)g(a)h(ne)n(w)f(reference)f(to)h(it.)27
b(It)20 b(may)g(then)g(be)g(called)h(at)g(a)f(later)208
4019 y(time)j(when)g(this)h(ne)n(w)g(reference)e(is)i(deleted.)34
b(It)24 b(is)h(not)e(guaranteed)e(that)j Fo(__del__\(\))f
Ft(methods)f(are)h(called)h(for)f(objects)208 4119 y(that)d(still)h(e)o
(xist)g(when)e(the)h(interpreter)f(e)o(xits.)208 4252
y Fr(Note:)37 b Ft(`)p Fo(del)48 b(x)p Ft(')27 b(doesn')o(t)e(directly)
h(call)h Fo(x.__del__\(\))e Ft(\227)i(the)f(former)f(decrements)g(the)i
(reference)e(count)g(for)h Fo(x)h Ft(by)208 4351 y(one,)h(and)f(the)h
(latter)g(is)h(only)e(called)g(when)g Fo(x)p Ft(')-5
b(s)29 b(reference)d(count)g(reaches)i(zero.)46 b(Some)28
b(common)e(situations)h(that)h(may)208 4451 y(pre)n(v)o(ent)18
b(the)j(reference)e(count)g(of)i(an)f(object)g(from)g(going)f(to)i
(zero)f(include:)25 b(circular)19 b(references)h(between)f(objects)i
(\(e.g.,)e(a)208 4551 y(doubly-link)o(ed)g(list)k(or)f(a)h(tree)f(data)
h(structure)e(with)i(parent)e(and)h(child)g(pointers\);)g(a)h
(reference)e(to)i(the)f(object)g(on)g(the)g(stack)208
4650 y(frame)f(of)i(a)g(function)e(that)i(caught)e(an)i(e)o(xception)e
(\(the)h(traceback)f(stored)h(in)h Fo(sys.exc_traceback)d
Ft(k)o(eeps)j(the)f(stack)208 4750 y(frame)j(ali)n(v)o(e\);)i(or)f(a)g
(reference)e(to)i(the)g(object)f(on)h(the)g(stack)g(frame)f(that)g
(raised)h(an)g(unhandled)d(e)o(xception)h(in)i(interacti)n(v)o(e)208
4850 y(mode)e(\(the)h(traceback)f(stored)g(in)i Fo(sys.last_traceback)c
Ft(k)o(eeps)j(the)h(stack)f(frame)g(ali)n(v)o(e\).)39
b(The)25 b(\002rst)h(situation)f(can)208 4949 y(only)f(be)h(remedied)f
(by)g(e)o(xplicitly)h(breaking)e(the)i(c)o(ycles;)j(the)d(latter)g(tw)o
(o)h(situations)f(can)g(be)g(resolv)o(ed)f(by)g(storing)h
Fo(None)208 5049 y Ft(in)d Fo(sys.exc_traceback)e Ft(or)h
Fo(sys.last_traceback)p Ft(.)29 b(Circular)21 b(references)g(which)h
(are)g(garbage)e(are)i(detected)208 5149 y(when)d(the)g(option)g(c)o
(ycle)g(detector)f(is)j(enabled)d(\(it')-5 b(s)21 b(on)e(by)g(def)o
(ault\),)g(b)n(ut)g(can)h(only)f(be)g(cleaned)g(up)g(if)h(there)f(are)h
(no)f(Python-)208 5248 y(le)n(v)o(el)29 b Fo(__del__\(\))g
Ft(methods)f(in)m(v)n(olv)o(ed.)52 b(Refer)30 b(to)g(the)g
(documentation)c(for)k(the)f Fo(gc)h Ft(module)f(for)g(more)g
(information)p 0 5314 1560 4 v 90 5370 a Ff(2)120 5393
y Fl(This,)16 b(and)h(other)h(statements,)h(are)f(only)f(roughly)i
(true)f(for)f(instances)i(of)e(ne)n(w-style)i(classes.)p
0 5549 3901 4 v 0 5649 a Fp(22)2944 b(Chapter)24 b(3.)52
b(Data)23 b(model)p eop end
%%Page: 23 29
TeXDict begin 23 28 bop 208 83 a Ft(about)15 b(ho)n(w)h
Fo(__del__\(\))g Ft(methods)f(are)i(handled)e(by)h(the)g(c)o(ycle)g
(detector)m(,)g(particularly)f(the)h(description)f(of)i(the)f
Fo(garbage)208 183 y Ft(v)n(alue.)p 208 242 3693 17 v
208 1213 17 972 v 282 357 a Fr(W)-5 b(ar)o(ning:)45 b
Ft(Due)16 b(to)f(the)h(precarious)e(circumstances)g(under)g(which)h
Fo(__del__\(\))f Ft(methods)h(are)g(in)m(v)n(ok)o(ed,)f(e)o(xceptions)
282 457 y(that)29 b(occur)e(during)f(their)i(e)o(x)o(ecution)e(are)i
(ignored,)g(and)g(a)h(w)o(arning)e(is)i(printed)e(to)h
Fo(sys.stderr)f Ft(instead.)49 b(Also,)282 556 y(when)21
b Fo(__del__\(\))f Ft(is)i(in)m(v)n(ok)o(ed)d(in)j(response)e(to)h(a)h
(module)e(being)g(deleted)g(\(e.g.,)g(when)h(e)o(x)o(ecution)e(of)i
(the)g(program)282 656 y(is)29 b(done\),)e(other)g(globals)g
(referenced)e(by)j(the)f Fo(__del__\(\))g Ft(method)f(may)h(already)f
(ha)n(v)o(e)h(been)g(deleted.)46 b(F)o(or)27 b(this)282
756 y(reason,)32 b Fo(__del__\(\))d Ft(methods)g(should)g(do)h(the)g
(absolute)g(minimum)e(needed)h(to)h(maintain)g(e)o(xternal)e(in)m(v)n
(ariants.)282 855 y(Starting)23 b(with)g(v)o(ersion)f(1.5,)g(Python)g
(guarantees)g(that)h(globals)f(whose)h(name)g(be)o(gins)f(with)h(a)g
(single)g(underscore)e(are)282 955 y(deleted)f(from)f(their)h(module)f
(before)g(other)h(globals)g(are)g(deleted;)g(if)g(no)g(other)g
(references)f(to)h(such)g(globals)g(e)o(xist,)g(this)282
1055 y(may)g(help)f(in)h(assuring)f(that)h(imported)e(modules)g(are)i
(still)h(a)n(v)n(ailable)e(at)h(the)g(time)g(when)f(the)h
Fo(__del__\(\))f Ft(method)f(is)282 1154 y(called.)p
3883 1213 V 208 1230 3693 17 v 0 1342 a Fh(__repr__)p
Fo(\()p Fq(self)12 b Fo(\))208 1442 y Ft(Called)27 b(by)h(the)f
Fo(repr\(\))g Ft(b)n(uilt-in)g(function)f(and)h(by)g(string)g(con)m(v)o
(ersions)e(\(re)n(v)o(erse)h(quotes\))h(to)h(compute)e(the)h(\223of)n
(\002cial\224)208 1542 y(string)18 b(representation)f(of)i(an)g
(object.)24 b(If)19 b(at)h(all)g(possible,)f(this)g(should)g(look)f
(lik)o(e)h(a)h(v)n(alid)f(Python)f(e)o(xpression)f(that)i(could)g(be)
208 1641 y(used)e(to)g(recreate)g(an)g(object)g(with)h(the)f(same)h(v)n
(alue)e(\(gi)n(v)o(en)g(an)h(appropriate)e(en)m(vironment\).)21
b(If)c(this)h(is)h(not)e(possible,)g(a)h(string)208 1741
y(of)23 b(the)g(form)g(`)p Fo(<)p Fq(...some)f(useful)h(description...)
p Fo(>)p Ft(')e(should)i(be)g(returned.)33 b(The)23 b(return)f(v)n
(alue)h(must)g(be)h(a)g(string)f(object.)34 b(If)23 b(a)208
1840 y(class)g(de\002nes)g Fo(__repr__\(\))f Ft(b)n(ut)g(not)h
Fo(__str__\(\))p Ft(,)f(then)h Fo(__repr__\(\))e Ft(is)j(also)f(used)g
(when)f(an)h(\223informal\224)e(string)208 1940 y(representation)d(of)i
(instances)g(of)g(that)g(class)h(is)g(required.)208 2073
y(This)d(is)h(typically)f(used)g(for)f(deb)n(ugging,)f(so)j(it)g(is)g
(important)e(that)h(the)h(representation)d(is)j(information-rich)c(and)
i(unambigu-)208 2173 y(ous.)0 2319 y Fh(__str__)p Fo(\()p
Fq(self)12 b Fo(\))208 2419 y Ft(Called)21 b(by)f(the)h
Fo(str\(\))f Ft(b)n(uilt-in)g(function)f(and)i(by)f(the)h
Fo(print)f Ft(statement)h(to)g(compute)e(the)i(\223informal\224)e
(string)h(represen-)208 2519 y(tation)h(of)h(an)g(object.)31
b(This)22 b(dif)n(fers)f(from)g Fo(__repr__\(\))g Ft(in)i(that)f(it)h
(does)f(not)f(ha)n(v)o(e)h(to)g(be)g(a)h(v)n(alid)f(Python)f(e)o
(xpression:)27 b(a)208 2618 y(more)19 b(con)m(v)o(enient)e(or)j
(concise)g(representation)e(may)i(be)g(used)g(instead.)25
b(The)19 b(return)g(v)n(alue)h(must)g(be)g(a)h(string)f(object.)0
2765 y Fh(__lt__)p Fo(\()p Fq(self)o(,)g(other)r Fo(\))0
2865 y Fh(__le__)p Fo(\()p Fq(self)o(,)g(other)r Fo(\))0
2964 y Fh(__eq__)p Fo(\()p Fq(self)o(,)g(other)r Fo(\))0
3064 y Fh(__ne__)p Fo(\()p Fq(self)o(,)g(other)r Fo(\))0
3164 y Fh(__gt__)p Fo(\()p Fq(self)o(,)g(other)r Fo(\))0
3263 y Fh(__ge__)p Fo(\()p Fq(self)o(,)g(other)r Fo(\))208
3363 y Ft(Ne)n(w)c(in)g(v)o(ersion)f(2.1.)47 b(These)16
b(are)g(the)g(so-called)g(\223rich)f(comparison\224)f(methods,)i(and)g
(are)g(called)g(for)f(comparison)f(operators)208 3463
y(in)24 b(preference)e(to)j Fo(__cmp__\(\))e Ft(belo)n(w)-5
b(.)37 b(The)24 b(correspondence)d(between)i(operator)g(symbols)h(and)f
(method)g(names)i(is)g(as)208 3562 y(follo)n(ws:)g Fq(x)p
Fo(<)p Fq(y)c Ft(calls)g Fq(x)p Fo(.__lt__\()p Fq(y)p
Fo(\))p Ft(,)e Fq(x)p Fo(<=)p Fq(y)i Ft(calls)g Fq(x)p
Fo(.__le__\()p Fq(y)p Fo(\))p Ft(,)e Fq(x)p Fo(==)p Fq(y)i
Ft(calls)g Fq(x)p Fo(.__eq__\()p Fq(y)p Fo(\))p Ft(,)e
Fq(x)p Fo(!=)p Fq(y)i Ft(and)e Fq(x)p Fo(<>)p Fq(y)i
Ft(call)208 3662 y Fq(x)p Fo(.__ne__\()p Fq(y)p Fo(\))p
Ft(,)d Fq(x)p Fo(>)p Fq(y)j Ft(calls)g Fq(x)p Fo(.__gt__\()p
Fq(y)p Fo(\))p Ft(,)e(and)g Fq(x)p Fo(>=)p Fq(y)i Ft(calls)g
Fq(x)p Fo(.__ge__\()p Fq(y)p Fo(\))p Ft(.)208 3795 y(A)e(rich)g
(comparison)e(method)h(may)h(return)f(the)h(singleton)g
Fo(NotImplemented)e Ft(if)i(it)h(does)f(not)g(implement)f(the)h
(operation)208 3894 y(for)28 b(a)i(gi)n(v)o(en)e(pair)h(of)g(ar)o
(guments.)50 b(By)30 b(con)m(v)o(ention,)e Fo(False)h
Ft(and)g Fo(True)g Ft(are)g(returned)e(for)i(a)h(successful)f
(comparison.)208 3994 y(Ho)n(we)n(v)o(er)m(,)20 b(these)i(methods)f
(can)h(return)e(an)o(y)i(v)n(alue,)f(so)h(if)h(the)f(comparison)e
(operator)g(is)j(used)e(in)h(a)h(Boolean)e(conte)o(xt)g(\(e.g.,)208
4093 y(in)g(the)h(condition)e(of)h(an)h Fo(if)g Ft(statement\),)f
(Python)f(will)j(call)f Fo(bool\(\))f Ft(on)g(the)h(v)n(alue)f(to)g
(determine)g(if)h(the)f(result)h(is)h(true)e(or)208 4193
y(f)o(alse.)208 4326 y(There)16 b(are)i(no)f(implied)f(relationships)h
(among)f(the)h(comparison)f(operators.)22 b(The)17 b(truth)g(of)g
Fq(x)p Fo(==)p Fq(y)h Ft(does)f(not)g(imply)g(that)g
Fq(x)p Fo(!=)p Fq(y)208 4426 y Ft(is)22 b(f)o(alse.)31
b(Accordingly)-5 b(,)19 b(when)i(de\002ning)f Fo(__eq__\(\))p
Ft(,)h(one)h(should)e(also)j(de\002ne)e Fo(__ne__\(\))g
Ft(so)h(that)g(the)g(operators)e(will)208 4525 y(beha)n(v)o(e)f(as)h(e)
o(xpected.)208 4658 y(There)h(are)i(no)f(re\003ected)f(\(sw)o(apped-ar)
o(gument\))d(v)o(ersions)k(of)g(these)g(methods)g(\(to)g(be)h(used)f
(when)g(the)g(left)h(ar)o(gument)d(does)208 4758 y(not)27
b(support)g(the)h(operation)f(b)n(ut)h(the)g(right)g(ar)o(gument)e
(does\);)31 b(rather)m(,)e Fo(__lt__\(\))e Ft(and)h Fo(__gt__\(\))f
Ft(are)h(each)g(other')-5 b(s)208 4857 y(re\003ection,)25
b Fo(__le__\(\))f Ft(and)h Fo(__ge__\(\))f Ft(are)h(each)g(other')-5
b(s)25 b(re\003ection,)g(and)g Fo(__eq__\(\))f Ft(and)g
Fo(__ne__\(\))h Ft(are)g(their)208 4957 y(o)n(wn)19 b(re\003ection.)208
5090 y(Ar)o(guments)f(to)i(rich)g(comparison)e(methods)h(are)h(ne)n(v)o
(er)f(coerced.)0 5237 y Fh(__cmp__)p Fo(\()p Fq(self)o(,)h(other)r
Fo(\))208 5336 y Ft(Called)g(by)f(comparison)f(operations)g(if)j(rich)e
(comparison)f(\(see)i(abo)o(v)o(e\))e(is)j(not)e(de\002ned.)24
b(Should)19 b(return)g(a)h(ne)o(gati)n(v)o(e)e(inte)o(ger)p
0 5549 3901 4 v 0 5649 a Fp(3.4.)52 b(Special)24 b(method)g(names)2774
b(23)p eop end
%%Page: 24 30
TeXDict begin 24 29 bop 208 83 a Ft(if)19 b Fo(self)49
b(<)g(other)p Ft(,)19 b(zero)f(if)h Fo(self)49 b(==)h(other)p
Ft(,)18 b(a)i(positi)n(v)o(e)e(inte)o(ger)f(if)j Fo(self)49
b(>)g(other)p Ft(.)24 b(If)19 b(no)g Fo(__cmp__\(\))p
Ft(,)e Fo(_-)208 183 y(_eq__\(\))i Ft(or)g Fo(__ne__\(\))g
Ft(operation)f(is)i(de\002ned,)f(class)h(instances)g(are)g(compared)d
(by)j(object)f(identity)g(\(\223address\224\).)k(See)208
282 y(also)c(the)h(description)e(of)i Fo(__hash__\(\))e
Ft(for)h(some)g(important)f(notes)i(on)f(creating)g(objects)g(which)g
(support)f(custom)h(com-)208 382 y(parison)j(operations)h(and)g(are)h
(usable)f(as)i(dictionary)d(k)o(e)o(ys.)36 b(\(Note:)c(the)24
b(restriction)f(that)h(e)o(xceptions)e(are)i(not)g(propagated)208
482 y(by)19 b Fo(__cmp__\(\))g Ft(has)i(been)e(remo)o(v)o(ed)f(since)i
(Python)f(1.5.\))0 628 y Fh(__rcmp__)p Fo(\()p Fq(self)o(,)g(other)r
Fo(\))208 728 y Ft(Changed)f(in)j(v)o(ersion)e(2.1:)g(No)i(longer)d
(supported.)0 875 y Fh(__hash__)p Fo(\()p Fq(self)12
b Fo(\))208 975 y Ft(Called)23 b(for)f(the)h(k)o(e)o(y)f(object)g(for)g
(dictionary)45 b(operations,)22 b(and)g(by)g(the)h(b)n(uilt-in)f
(function)f Fo(hash\(\))p Ft(.)33 b(Should)21 b(return)h(a)h(32-)208
1074 y(bit)j(inte)o(ger)f(usable)h(as)h(a)g(hash)f(v)n(alue)g(for)g
(dictionary)e(operations.)42 b(The)26 b(only)g(required)e(property)g
(is)k(that)e(objects)g(which)208 1174 y(compare)d(equal)g(ha)n(v)o(e)h
(the)h(same)g(hash)f(v)n(alue;)i(it)f(is)h(advised)e(to)g(someho)n(w)g
(mix)g(together)f(\(e.g.,)h(using)h(e)o(xclusi)n(v)o(e)e(or\))h(the)208
1273 y(hash)e(v)n(alues)h(for)f(the)h(components)d(of)j(the)g(object)f
(that)h(also)g(play)f(a)h(part)g(in)g(comparison)e(of)h(objects.)33
b(If)22 b(a)i(class)f(does)g(not)208 1373 y(de\002ne)e(a)h
Fo(__cmp__\(\))f Ft(method)g(it)h(should)f(not)h(de\002ne)f(a)h
Fo(__hash__\(\))f Ft(operation)f(either;)i(if)g(it)h(de\002nes)f
Fo(__cmp__\(\))208 1473 y Ft(or)28 b Fo(__eq__\(\))g
Ft(b)n(ut)g(not)h Fo(__hash__\(\))p Ft(,)g(its)h(instances)e(will)i
(not)e(be)h(usable)f(as)i(dictionary)c(k)o(e)o(ys.)51
b(If)28 b(a)h(class)h(de\002nes)208 1572 y(mutable)20
b(objects)h(and)f(implements)g(a)i Fo(__cmp__\(\))e Ft(or)h
Fo(__eq__\(\))f Ft(method,)g(it)i(should)e(not)h(implement)f
Fo(__hash__-)208 1672 y(\(\))p Ft(,)f(since)g(the)g(dictionary)e
(implementation)g(requires)g(that)j(a)f(k)o(e)o(y')-5
b(s)19 b(hash)f(v)n(alue)g(is)i(immutable)e(\(if)h(the)g(object')-5
b(s)19 b(hash)f(v)n(alue)208 1772 y(changes,)g(it)j(will)g(be)f(in)h
(the)f(wrong)f(hash)h(b)n(uck)o(et\).)208 1904 y(Changed)26
b(in)i(v)o(ersion)e(2.5:)h Fo(__hash__\(\))f Ft(may)h(no)n(w)g(also)h
(return)e(a)i(long)f(inte)o(ger)f(object;)31 b(the)d(32-bit)e(inte)o
(ger)h(is)h(then)208 2004 y(deri)n(v)o(ed)18 b(from)h(the)h(hash)g(of)g
(that)g(object.)0 2151 y Fh(__nonzero__)p Fo(\()p Fq(self)12
b Fo(\))208 2250 y Ft(Called)21 b(to)h(implement)e(truth)h(v)n(alue)f
(testing,)i(and)f(the)g(b)n(uilt-in)g(operation)e Fo(bool\(\))p
Ft(;)j(should)e(return)g Fo(False)h Ft(or)h Fo(True)p
Ft(,)f(or)208 2350 y(their)j(inte)o(ger)g(equi)n(v)n(alents)f
Fo(0)j Ft(or)e Fo(1)p Ft(.)40 b(When)24 b(this)i(method)d(is)j(not)f
(de\002ned,)g Fo(__len__\(\))e Ft(is)j(called,)g(if)f(it)h(is)f
(de\002ned)f(\(see)208 2450 y(belo)n(w\).)g(If)c(a)g(class)h(de\002nes)
f(neither)g Fo(__len__\(\))f Ft(nor)g Fo(__nonzero__\(\))p
Ft(,)f(all)j(its)g(instances)f(are)g(considered)f(true.)0
2597 y Fh(__unicode__)p Fo(\()p Fq(self)12 b Fo(\))208
2696 y Ft(Called)26 b(to)g(implement)e Fo(unicode\(\))h
Ft(b)n(uiltin;)j(should)d(return)f(a)j(Unicode)d(object.)41
b(When)26 b(this)g(method)f(is)h(not)g(de\002ned,)208
2796 y(string)j(con)m(v)o(ersion)d(is)k(attempted,)h(and)d(the)i
(result)f(of)g(string)g(con)m(v)o(ersion)e(is)j(con)m(v)o(erted)d(to)i
(Unicode)f(using)h(the)g(system)208 2895 y(def)o(ault)19
b(encoding.)0 3180 y Fk(3.4.2)100 b(Customizing)29 b(attr)q(ib)n(ute)g
(access)0 3383 y Ft(The)19 b(follo)n(wing)f(methods)h(can)g(be)g
(de\002ned)g(to)h(customize)e(the)i(meaning)e(of)h(attrib)n(ute)g
(access)h(\(use)g(of,)f(assignment)g(to,)g(or)h(deletion)0
3483 y(of)g Fo(x.name)p Ft(\))f(for)h(class)h(instances.)0
3630 y Fh(__getattr__)p Fo(\()p Fq(self)o(,)e(name)p
Fo(\))208 3729 y Ft(Called)h(when)f(an)h(attrib)n(ute)f(lookup)f(has)i
(not)g(found)e(the)i(attrib)n(ute)f(in)i(the)e(usual)h(places)g(\(i.e.)
25 b(it)20 b(is)h(not)f(an)f(instance)h(attrib)n(ute)208
3829 y(nor)15 b(is)j(it)f(found)e(in)i(the)f(class)i(tree)f(for)f
Fo(self)p Ft(\).)23 b Fo(name)16 b Ft(is)i(the)e(attrib)n(ute)h(name.)
23 b(This)16 b(method)g(should)f(return)h(the)g(\(computed\))208
3929 y(attrib)n(ute)j(v)n(alue)h(or)g(raise)g(an)g Fo(AttributeError)f
Ft(e)o(xception.)208 4062 y(Note)j(that)g(if)h(the)f(attrib)n(ute)g(is)
i(found)c(through)g(the)j(normal)e(mechanism,)g Fo(__getattr__\(\))g
Ft(is)i(not)f(called.)31 b(\(This)22 b(is)i(an)208 4161
y(intentional)f(asymmetry)h(between)g Fo(__getattr__\(\))f
Ft(and)h Fo(__setattr__\(\))p Ft(.\))37 b(This)26 b(is)g(done)d(both)i
(for)f(ef)n(\002cienc)o(y)208 4261 y(reasons)18 b(and)g(because)g
(otherwise)h Fo(__setattr__\(\))e Ft(w)o(ould)h(ha)n(v)o(e)g(no)h(w)o
(ay)f(to)h(access)h(other)e(attrib)n(utes)h(of)f(the)h(instance.)208
4360 y(Note)25 b(that)h(at)g(least)g(for)f(instance)g(v)n(ariables,)h
(you)e(can)i(f)o(ak)o(e)f(total)h(control)e(by)h(not)g(inserting)g(an)o
(y)g(v)n(alues)g(in)g(the)h(instance)208 4460 y(attrib)n(ute)e
(dictionary)g(\(b)n(ut)h(instead)g(inserting)f(them)h(in)g(another)f
(object\).)40 b(See)25 b(the)g Fo(__getattribute__\(\))e
Ft(method)208 4560 y(belo)n(w)c(for)h(a)g(w)o(ay)h(to)f(actually)f(get)
i(total)f(control)f(in)h(ne)n(w-style)g(classes.)0 4707
y Fh(__setattr__)p Fo(\()p Fq(self)o(,)f(name)o(,)g(value)p
Fo(\))208 4806 y Ft(Called)h(when)f(an)h(attrib)n(ute)f(assignment)g
(is)i(attempted.)j(This)c(is)h(called)f(instead)f(of)h(the)g(normal)f
(mechanism)f(\(i.e.)i(store)g(the)208 4906 y(v)n(alue)f(in)h(the)h
(instance)e(dictionary\).)k Fq(name)d Ft(is)h(the)f(attrib)n(ute)g
(name,)f Fq(value)h Ft(is)h(the)f(v)n(alue)g(to)g(be)g(assigned)g(to)g
(it.)208 5039 y(If)28 b Fo(__setattr__\(\))e Ft(w)o(ants)j(to)g(assign)
f(to)g(an)h(instance)f(attrib)n(ute,)h(it)h(should)d(not)h(simply)g(e)o
(x)o(ecute)f(`)p Fo(self.)p Fq(name)47 b Fo(=)208 5138
y(value)p Ft(')26 b(\227)i(this)g(w)o(ould)e(cause)h(a)h(recursi)n(v)o
(e)e(call)h(to)h(itself.)46 b(Instead,)29 b(it)e(should)g(insert)g(the)
g(v)n(alue)g(in)g(the)g(dictionary)f(of)208 5238 y(instance)21
b(attrib)n(utes,)h(e.g.,)f(`)p Fo(self.__dict__[)p Fq(name)p
Fo(])45 b(=)50 b(value)p Ft('.)29 b(F)o(or)21 b(ne)n(w-style)g
(classes,)i(rather)e(than)g(accessing)208 5337 y(the)h(instance)h
(dictionary)-5 b(,)21 b(it)j(should)d(call)j(the)e(base)h(class)h
(method)e(with)h(the)g(same)g(name,)f(for)g(e)o(xample,)g(`)p
Fo(object.__-)p 0 5549 3901 4 v 0 5649 a Fp(24)2944 b(Chapter)24
b(3.)52 b(Data)23 b(model)p eop end
%%Page: 25 31
TeXDict begin 25 30 bop 208 83 a Fo(setattr__\(self,)47
b(name,)h(value\))p Ft('.)0 230 y Fh(__delattr__)p Fo(\()p
Fq(self)o(,)19 b(name)p Fo(\))208 330 y Ft(Lik)o(e)24
b Fo(__setattr__\(\))g Ft(b)n(ut)g(for)h(attrib)n(ute)f(deletion)g
(instead)h(of)g(assignment.)38 b(This)25 b(should)f(only)g(be)h
(implemented)e(if)208 429 y(`)p Fo(del)48 b(obj.)p Fq(name)p
Ft(')19 b(is)i(meaningful)d(for)i(the)g(object.)0 697
y Fp(More)j(attr)q(ib)n(ute)i(access)c(f)n(or)i(ne)n(w-style)g(classes)
0 900 y Ft(The)d(follo)n(wing)e(methods)i(only)f(apply)g(to)h(ne)n
(w-style)g(classes.)0 1047 y Fh(__getattribute__)p Fo(\()p
Fq(self)o(,)e(name)p Fo(\))208 1147 y Ft(Called)33 b(unconditionally)d
(to)j(implement)f(attrib)n(ute)h(accesses)h(for)f(instances)g(of)g(the)
g(class.)65 b(If)33 b(the)g(class)h(also)g(de\002nes)208
1246 y Fo(__getattr__\(\))p Ft(,)j(the)e(latter)h(will)g(not)f(be)h
(called)f(unless)g Fo(__getattribute__\(\))e Ft(either)i(calls)h(it)h
(e)o(xplicitly)208 1346 y(or)g(raises)i(an)f Fo(AttributeError)p
Ft(.)76 b(This)38 b(method)f(should)g(return)g(the)g(\(computed\))f
(attrib)n(ute)h(v)n(alue)h(or)f(raise)i(an)208 1446 y
Fo(AttributeError)15 b Ft(e)o(xception.)22 b(In)17 b(order)e(to)j(a)n
(v)n(oid)f(in\002nite)g(recursion)e(in)i(this)h(method,)e(its)i
(implementation)d(should)h(al-)208 1545 y(w)o(ays)h(call)g(the)f(base)h
(class)h(method)d(with)i(the)g(same)f(name)h(to)f(access)i(an)o(y)e
(attrib)n(utes)g(it)i(needs,)e(for)g(e)o(xample,)g(`)p
Fo(object._-)208 1645 y(_getattribute__\(self,)45 b(name\))p
Ft('.)0 1913 y Fp(Implementing)25 b(Descr)q(iptors)0
2116 y Ft(The)c(follo)n(wing)f(methods)h(only)g(apply)g(when)g(an)h
(instance)f(of)g(the)h(class)h(containing)d(the)h(method)g(\(a)g
(so-called)g Fq(descriptor)h Ft(class\))0 2216 y(appears)27
b(in)h(the)g(class)h(dictionary)e(of)g(another)g(ne)n(w-style)g(class,)
k(kno)n(wn)c(as)h(the)h Fq(owner)f Ft(class.)49 b(In)28
b(the)g(e)o(xamples)f(belo)n(w)-5 b(,)29 b(\223the)0
2315 y(attrib)n(ute\224)c(refers)f(to)i(the)f(attrib)n(ute)f(whose)h
(name)g(is)h(the)f(k)o(e)o(y)f(of)h(the)g(property)e(in)j(the)f(o)n
(wner)f(class')h Fo(__dict__)p Ft(.)39 b(Descriptors)0
2415 y(can)20 b(only)f(be)h(implemented)f(as)i(ne)n(w-style)e(classes)i
(themselv)o(es.)0 2562 y Fh(__get__)p Fo(\()p Fq(self)o(,)f(instance)o
(,)f(owner)r Fo(\))208 2662 y Ft(Called)28 b(to)h(get)f(the)g(attrib)n
(ute)g(of)g(the)h(o)n(wner)e(class)i(\(class)g(attrib)n(ute)f(access\))
g(or)g(of)g(an)h(instance)f(of)g(that)g(class)h(\(instance)208
2761 y(attrib)n(ute)20 b(access\).)26 b Fq(owner)c Ft(is)g(al)o(w)o
(ays)f(the)f(o)n(wner)g(class,)h(while)g Fq(instance)f
Ft(is)h(the)g(instance)f(that)h(the)f(attrib)n(ute)g(w)o(as)i(accessed)
208 2861 y(through,)c(or)j Fo(None)g Ft(when)f(the)h(attrib)n(ute)g(is)
h(accessed)f(through)e(the)i Fq(owner)r Ft(.)27 b(This)22
b(method)d(should)h(return)g(the)h(\(computed\))208 2960
y(attrib)n(ute)e(v)n(alue)h(or)g(raise)g(an)g Fo(AttributeError)f
Ft(e)o(xception.)0 3107 y Fh(__set__)p Fo(\()p Fq(self)o(,)h(instance)o
(,)f(value)p Fo(\))208 3207 y Ft(Called)h(to)g(set)h(the)g(attrib)n
(ute)e(on)h(an)g(instance)g Fq(instance)g Ft(of)g(the)g(o)n(wner)f
(class)i(to)f(a)h(ne)n(w)f(v)n(alue,)f Fq(value)p Ft(.)0
3354 y Fh(__delete__)p Fo(\()p Fq(self)o(,)g(instance)p
Fo(\))208 3453 y Ft(Called)h(to)g(delete)g(the)h(attrib)n(ute)e(on)h
(an)g(instance)g Fq(instance)g Ft(of)g(the)g(o)n(wner)f(class.)0
3722 y Fp(In)n(v)n(oking)24 b(Descr)q(iptors)0 3925 y
Ft(In)c(general,)f(a)i(descriptor)e(is)i(an)g(object)f(attrib)n(ute)g
(with)g(\223binding)f(beha)n(vior\224,)f(one)i(whose)g(attrib)n(ute)g
(access)h(has)g(been)f(o)o(v)o(erridden)0 4024 y(by)j(methods)g(in)h
(the)f(descriptor)g(protocol:)30 b Fo(__get__\(\))p Ft(,)23
b Fo(__set__\(\))p Ft(,)g(and)h Fo(__delete__\(\))p Ft(.)33
b(If)24 b(an)o(y)f(of)g(those)h(methods)0 4124 y(are)c(de\002ned)f(for)
h(an)g(object,)f(it)i(is)g(said)g(to)f(be)g(a)h(descriptor)-5
b(.)0 4271 y(The)20 b(def)o(ault)h(beha)n(vior)e(for)h(attrib)n(ute)g
(access)i(is)f(to)g(get,)g(set,)h(or)e(delete)h(the)g(attrib)n(ute)f
(from)g(an)h(object')-5 b(s)20 b(dictionary)-5 b(.)25
b(F)o(or)20 b(instance,)0 4370 y Fo(a.x)30 b Ft(has)h(a)f(lookup)f
(chain)g(starting)h(with)g Fo(a.__dict__['x'])p Ft(,)g(then)g
Fo(type\(a\).__dict__['x'])p Ft(,)f(and)h(continuing)0
4470 y(through)18 b(the)i(base)h(classes)g(of)f Fo(type\(a\))f
Ft(e)o(xcluding)f(metaclasses.)0 4617 y(Ho)n(we)n(v)o(er)m(,)26
b(if)g(the)h(look)o(ed-up)d(v)n(alue)h(is)j(an)e(object)g(de\002ning)f
(one)h(of)g(the)g(descriptor)f(methods,)i(then)e(Python)h(may)f(o)o(v)o
(erride)g(the)0 4716 y(def)o(ault)i(beha)n(vior)f(and)h(in)m(v)n(ok)o
(e)f(the)i(descriptor)e(method)g(instead.)47 b(Where)28
b(this)g(occurs)f(in)h(the)f(precedence)f(chain)h(depends)f(on)0
4816 y(which)18 b(descriptor)e(methods)i(were)g(de\002ned)f(and)h(ho)n
(w)f(the)o(y)h(were)g(called.)24 b(Note)18 b(that)g(descriptors)g(are)g
(only)f(in)m(v)n(ok)o(ed)g(for)g(ne)n(w)h(style)0 4916
y(objects)i(or)g(classes)h(\(ones)f(that)g(subclass)g
Fo(object\(\))g Ft(or)g Fo(type\(\))p Ft(\).)0 5063 y(The)g(starting)g
(point)f(for)h(descriptor)e(in)m(v)n(ocation)h(is)i(a)f(binding,)f
Fo(a.x)p Ft(.)25 b(Ho)n(w)20 b(the)g(ar)o(guments)e(are)i(assembled)g
(depends)f(on)g Fo(a)p Ft(:)-201 5293 y(Direct)i(Call)42
b(The)19 b(simplest)h(and)f(least)h(common)e(call)i(is)h(when)e(user)g
(code)g(directly)g(in)m(v)n(ok)o(es)g(a)h(descriptor)e(method:)23
b Fo(x.__get__\(a\))p Ft(.)p 0 5549 3901 4 v 0 5649 a
Fp(3.4.)52 b(Special)24 b(method)g(names)2774 b(25)p
eop end
%%Page: 26 32
TeXDict begin 26 31 bop -399 83 a Ft(Instance)19 b(Binding)41
b(If)21 b(binding)e(to)j(a)f(ne)n(w-style)g(object)g(instance,)g
Fo(a.x)g Ft(is)h(transformed)d(into)i(the)h(call:)27
b Fo(type\(a\).__dict__['x']._-)208 183 y(_get__\(a,)48
b(type\(a\)\))p Ft(.)-302 349 y(Class)21 b(Binding)41
b(If)27 b(binding)f(to)i(a)h(ne)n(w-style)e(class,)j
Fo(A.x)e Ft(is)h(transformed)c(into)j(the)f(call:)41
b Fo(A.__dict__['x'].__get__\(None,)208 448 y(A\))p Ft(.)-316
614 y(Super)19 b(Binding)41 b(If)29 b Fo(a)i Ft(is)g(an)f(instance)f
(of)h Fo(super)p Ft(,)i(then)e(the)g(binding)e Fo(super\(B,)48
b(obj\).m\(\))29 b Ft(searches)h Fo(obj.__class__.__-)208
714 y(mro__)e Ft(for)f(the)i(base)f(class)h Fo(A)g Ft(immediately)e
(preceding)f Fo(B)j Ft(and)f(then)g(in)m(v)n(ok)o(es)f(the)h
(descriptor)f(with)i(the)f(call:)42 b Fo(A.__-)208 814
y(dict__['m'].__get__\(obj,)j(A\))p Ft(.)0 1044 y(F)o(or)22
b(instance)g(bindings,)g(the)g(precedence)f(of)h(descriptor)f(in)m(v)n
(ocation)f(depends)h(on)i(the)f(which)g(descriptor)f(methods)g(are)i
(de\002ned.)0 1143 y(Data)16 b(descriptors)f(de\002ne)h(both)f
Fo(__get__\(\))g Ft(and)h Fo(__set__\(\))p Ft(.)22 b(Non-data)15
b(descriptors)g(ha)n(v)o(e)g(just)i(the)f Fo(__get__\(\))f
Ft(method.)0 1243 y(Data)30 b(descriptors)f(al)o(w)o(ays)i(o)o(v)o
(erride)d(a)i(rede\002nition)f(in)h(an)g(instance)g(dictionary)-5
b(.)53 b(In)30 b(contrast,)h(non-data)e(descriptors)g(can)h(be)0
1342 y(o)o(v)o(erridden)17 b(by)j(instances.)0 1489 y(Python)25
b(methods)h(\(including)e Fo(staticmethod\(\))g Ft(and)i
Fo(classmethod\(\))p Ft(\))e(are)j(implemented)d(as)j(non-data)e
(descriptors.)0 1589 y(Accordingly)-5 b(,)20 b(instances)i(can)g
(rede\002ne)g(and)f(o)o(v)o(erride)f(methods.)31 b(This)22
b(allo)n(ws)h(indi)n(vidual)d(instances)j(to)f(acquire)f(beha)n(viors)g
(that)0 1689 y(dif)n(fer)e(from)g(other)h(instances)g(of)g(the)g(same)g
(class.)0 1835 y(The)g Fo(property\(\))f Ft(function)f(is)j
(implemented)d(as)j(a)f(data)g(descriptor)-5 b(.)24 b(Accordingly)-5
b(,)17 b(instances)j(cannot)f(o)o(v)o(erride)f(the)i(beha)n(vior)0
1935 y(of)g(a)h(property)-5 b(.)p 5 2203 25 4 v 35 2203
V 60 2203 a Fp(slots)p 236 2203 V 265 2203 V 0 2406 a
Ft(By)24 b(def)o(ault,)f(instances)h(of)f(both)g(old)g(and)g(ne)n
(w-style)f(classes)j(ha)n(v)o(e)e(a)h(dictionary)d(for)i(attrib)n(ute)g
(storage.)35 b(This)23 b(w)o(astes)i(space)e(for)0 2506
y(objects)c(ha)n(ving)f(v)o(ery)g(fe)n(w)i(instance)f(v)n(ariables.)k
(The)c(space)h(consumption)d(can)i(become)f(acute)h(when)f(creating)h
(lar)o(ge)f(numbers)g(of)0 2605 y(instances.)0 2752 y(The)25
b(def)o(ault)h(can)f(be)h(o)o(v)o(erridden)c(by)k(de\002ning)p
1454 2752 V 1484 2752 V 84 w Fq(slots)p 1666 2752 V 1696
2752 V 86 w Ft(in)g(a)h(ne)n(w-style)e(class)i(de\002nition.)40
b(The)p 2979 2752 V 3008 2752 V 85 w Fq(slots)p 3190
2752 V 3220 2752 V 87 w Ft(declaration)24 b(tak)o(es)i(a)0
2852 y(sequence)17 b(of)i(instance)f(v)n(ariables)f(and)h(reserv)o(es)g
(just)h(enough)e(space)h(in)h(each)f(instance)g(to)h(hold)f(a)h(v)n
(alue)e(for)h(each)g(v)n(ariable.)24 b(Space)0 2952 y(is)d(sa)n(v)o(ed)
f(because)p 572 2952 V 601 2952 V 79 w Fq(dict)p 756
2952 V 786 2952 V 80 w Ft(is)i(not)d(created)h(for)f(each)h(instance.)0
3098 y Fh(__slots__)208 3198 y Ft(This)27 b(class)h(v)n(ariable)f(can)g
(be)g(assigned)g(a)h(string,)g(iterable,)g(or)g(sequence)e(of)h
(strings)g(with)h(v)n(ariable)e(names)h(used)g(by)g(in-)208
3298 y(stances.)56 b(If)30 b(de\002ned)f(in)i(a)g(ne)n(w-style)f
(class,)p 1622 3298 V 1652 3298 V 93 w Fq(slots)p 1834
3298 V 1864 3298 V 91 w Ft(reserv)o(es)g(space)g(for)g(the)h(declared)e
(v)n(ariables)h(and)g(pre)n(v)o(ents)f(the)208 3397 y(automatic)19
b(creation)g(of)p 939 3397 V 969 3397 V 80 w Fq(dict)p
1124 3397 V 1153 3397 V 80 w Ft(and)p 1344 3397 V 1374
3397 V 79 w Fq(weakr)m(ef)p 1664 3397 V 1694 3397 V 80
w Ft(for)h(each)g(instance.)50 b(Ne)n(w)20 b(in)h(v)o(ersion)e(2.2.)0
3544 y(Notes)h(on)g(using)p 524 3544 V 554 3544 V 80
w Fq(slots)p 736 3544 V 766 3544 V 125 3774 a Fs(\017)41
b Ft(W)m(ithout)30 b(a)p 581 3774 V 610 3774 V 90 w Fq(dict)p
765 3774 V 795 3774 V 91 w Ft(v)n(ariable,)i(instances)e(cannot)g(be)g
(assigned)g(ne)n(w)h(v)n(ariables)e(not)i(listed)g(in)f(the)p
3263 3774 V 3293 3774 V 91 w Fq(slots)p 3475 3774 V 3505
3774 V 91 w Ft(de\002nition.)208 3874 y(Attempts)f(to)g(assign)g(to)g
(an)g(unlisted)g(v)n(ariable)f(name)g(raises)i Fo(AttributeError)p
Ft(.)49 b(If)29 b(dynamic)f(assignment)g(of)h(ne)n(w)208
3973 y(v)n(ariables)19 b(is)j(desired,)d(then)h(add)g
Fo('__dict__')g Ft(to)g(the)h(sequence)e(of)h(strings)h(in)g(the)p
2788 3973 V 2818 3973 V 80 w Fq(slots)p 3000 3973 V 3030
3973 V 81 w Ft(declaration.)51 b(Changed)19 b(in)208
4073 y(v)o(ersion)k(2.3:)g(Pre)n(viously)-5 b(,)24 b(adding)f
Fo('__dict__')g Ft(to)h(the)p 2016 4073 V 2046 4073 V
84 w Fq(slots)p 2228 4073 V 2258 4073 V 85 w Ft(declaration)f(w)o(ould)
g(not)h(enable)g(the)g(assignment)g(of)208 4173 y(ne)n(w)c(attrib)n
(utes)g(not)g(speci\002cally)f(listed)i(in)f(the)h(sequence)e(of)h
(instance)f(v)n(ariable)g(names.)125 4339 y Fs(\017)41
b Ft(W)m(ithout)19 b(a)p 559 4339 V 589 4339 V 80 w Fq(weakr)m(ef)p
879 4339 V 909 4339 V 80 w Ft(v)n(ariable)g(for)g(each)h(instance,)f
(classes)i(de\002ning)p 2392 4339 V 2422 4339 V 79 w
Fq(slots)p 2604 4339 V 2634 4339 V 80 w Ft(do)f(not)g(support)e(weak)i
(references)e(to)j(its)208 4438 y(instances.)40 b(If)25
b(weak)g(reference)f(support)g(is)i(needed,)f(then)g(add)f
Fo('__weakref__')g Ft(to)h(the)h(sequence)e(of)h(strings)g(in)h(the)p
208 4538 V 237 4538 V 262 4538 a Fq(slots)p 419 4538
V 449 4538 V 79 w Ft(declaration.)48 b(Changed)17 b(in)h(v)o(ersion)f
(2.3:)h(Pre)n(viously)-5 b(,)17 b(adding)f Fo('__weakref__')h
Ft(to)h(the)p 3245 4538 V 3275 4538 V 78 w Fq(slots)p
3457 4538 V 3487 4538 V 79 w Ft(declaration)208 4638
y(w)o(ould)h(not)h(enable)f(support)g(for)h(weak)g(references.)125
4804 y Fs(\017)p 213 4804 V 242 4804 V 100 w Fq(slots)p
424 4804 V 454 4804 V 84 w Ft(are)k(implemented)d(at)j(the)g(class)g
(le)n(v)o(el)f(by)g(creating)g(descriptors)f(\(3.4.2\))f(for)i(each)g
(v)n(ariable)g(name.)34 b(As)24 b(a)g(result,)208 4903
y(class)j(attrib)n(utes)g(cannot)e(be)i(used)g(to)f(set)i(def)o(ault)e
(v)n(alues)g(for)g(instance)h(v)n(ariables)f(de\002ned)f(by)p
3106 4903 V 3136 4903 V 86 w Fq(slots)p 3317 4903 V 3348
4903 V 60 w Ft(;)31 b(otherwise,)d(the)208 5003 y(class)21
b(attrib)n(ute)f(w)o(ould)f(o)o(v)o(erwrite)f(the)j(descriptor)d
(assignment.)125 5169 y Fs(\017)41 b Ft(If)31 b(a)i(class)g(de\002nes)e
(a)i(slot)f(also)g(de\002ned)f(in)h(a)h(base)f(class,)j(the)d(instance)
g(v)n(ariable)f(de\002ned)g(by)g(the)h(base)g(class)h(slot)g(is)208
5268 y(inaccessible)24 b(\(e)o(xcept)e(by)i(retrie)n(ving)f(its)i
(descriptor)e(directly)g(from)h(the)g(base)g(class\).)38
b(This)24 b(renders)g(the)g(meaning)f(of)h(the)208 5368
y(program)18 b(unde\002ned.)23 b(In)c(the)i(future,)d(a)j(check)e(may)h
(be)g(added)f(to)i(pre)n(v)o(ent)d(this.)p 0 5549 3901
4 v 0 5649 a Fp(26)2944 b(Chapter)24 b(3.)52 b(Data)23
b(model)p eop end
%%Page: 27 33
TeXDict begin 27 32 bop 125 83 a Fs(\017)41 b Ft(The)19
b(action)g(of)g(a)p 731 83 25 4 v 761 83 V 79 w Fq(slots)p
942 83 V 973 83 V 80 w Ft(declaration)f(is)j(limited)e(to)h(the)f
(class)i(where)d(it)j(is)f(de\002ned.)k(As)c(a)g(result,)f(subclasses)h
(will)g(ha)n(v)o(e)f(a)p 208 183 V 237 183 V 262 183
a Fq(dict)p 392 183 V 422 183 V 80 w Ft(unless)i(the)o(y)e(also)i
(de\002ne)p 1241 183 V 1271 183 V 79 w Fq(slots)p 1453
183 V 1483 183 V 60 w Ft(.)125 349 y Fs(\017)p 213 349
V 242 349 V 100 w Fq(slots)p 424 349 V 454 349 V 81 w
Ft(do)f(not)g(w)o(ork)f(for)h(classes)h(deri)n(v)o(ed)e(from)g(\223v)n
(ariable-length\224)e(b)n(uilt-in)i(types)h(such)g(as)h
Fo(long)p Ft(,)f Fo(str)g Ft(and)g Fo(tuple)p Ft(.)125
515 y Fs(\017)41 b Ft(An)o(y)17 b(non-string)e(iterable)j(may)f(be)h
(assigned)f(to)p 1645 515 V 1675 515 V 78 w Fq(slots)p
1857 515 V 1887 515 V 60 w Ft(.)24 b(Mappings)17 b(may)g(also)h(be)g
(used;)g(ho)n(we)n(v)o(er)m(,)e(in)i(the)g(future,)e(special)208
614 y(meaning)i(may)i(be)g(assigned)g(to)g(the)g(v)n(alues)g
(corresponding)d(to)j(each)g(k)o(e)o(y)-5 b(.)0 899 y
Fk(3.4.3)100 b(Customizing)29 b(class)f(creation)0 1102
y Ft(By)21 b(def)o(ault,)e(ne)n(w-style)g(classes)j(are)e(constructed)e
(using)i Fo(type\(\))p Ft(.)k(A)d(class)g(de\002nition)e(is)i(read)f
(into)g(a)g(separate)g(namespace)f(and)0 1202 y(the)h(v)n(alue)g(of)g
(class)h(name)e(is)i(bound)e(to)h(the)g(result)h(of)e
Fo(type\(name,)48 b(bases,)h(dict\))p Ft(.)0 1349 y(When)24
b(the)g(class)h(de\002nition)e(is)i(read,)f(if)p 1228
1349 V 1258 1349 V 85 w Fq(metaclass)p 1616 1349 V 1645
1349 V 84 w Ft(is)h(de\002ned)e(then)g(the)i(callable)e(assigned)h(to)g
(it)h(will)g(be)f(called)g(instead)g(of)0 1448 y Fo(type\(\))p
Ft(.)g(The)c(allo)n(ws)h(classes)g(or)f(functions)f(to)h(be)g(written)g
(which)g(monitor)e(or)i(alter)h(the)f(class)h(creation)e(process:)125
1678 y Fs(\017)41 b Ft(Modifying)17 b(the)k(class)g(dictionary)d(prior)
h(to)i(the)f(class)h(being)e(created.)125 1844 y Fs(\017)41
b Ft(Returning)18 b(an)j(instance)e(of)h(another)f(class)i(\226)f
(essentially)h(performing)c(the)j(role)g(of)g(a)h(f)o(actory)e
(function.)0 2027 y Fh(__metaclass__)208 2127 y Ft(This)j(v)n(ariable)g
(can)h(be)f(an)o(y)g(callable)h(accepting)e(ar)o(guments)g(for)h
Fo(name)p Ft(,)h Fo(bases)p Ft(,)g(and)f Fo(dict)p Ft(.)32
b(Upon)22 b(class)h(creation,)g(the)208 2226 y(callable)d(is)h(used)f
(instead)g(of)f(the)i(b)n(uilt-in)e Fo(type\(\))p Ft(.)50
b(Ne)n(w)21 b(in)f(v)o(ersion)f(2.2.)0 2373 y(The)h(appropriate)e
(metaclass)i(is)h(determined)e(by)g(the)i(follo)n(wing)d(precedence)g
(rules:)125 2603 y Fs(\017)41 b Ft(If)20 b Fo(dict['__metaclass__'])c
Ft(e)o(xists,)21 b(it)g(is)g(used.)125 2769 y Fs(\017)41
b Ft(Otherwise,)21 b(if)h(there)f(is)i(at)f(least)g(one)f(base)h
(class,)h(its)f(metaclass)g(is)h(used)e(\(this)h(looks)f(for)g(a)p
2956 2769 V 2986 2769 V 82 w Fq(class)p 3182 2769 V 3212
2769 V 82 w Ft(attrib)n(ute)g(\002rst)h(and)f(if)208
2869 y(not)e(found,)g(uses)h(its)i(type\).)125 3035 y
Fs(\017)41 b Ft(Otherwise,)19 b(if)i(a)f(global)g(v)n(ariable)f(named)p
1481 3035 V 1511 3035 V 79 w(metaclass)p 1864 3035 V
1893 3035 V 80 w(e)o(xists,)h(it)h(is)g(used.)125 3201
y Fs(\017)41 b Ft(Otherwise,)19 b(the)h(old-style,)g(classic)h
(metaclass)f(\(types.ClassT)-7 b(ype\))19 b(is)i(used.)0
3431 y(The)27 b(potential)f(uses)h(for)f(metaclasses)i(are)f
(boundless.)44 b(Some)26 b(ideas)h(that)g(ha)n(v)o(e)g(been)f(e)o
(xplored)f(including)g(logging,)h(interf)o(ace)0 3530
y(checking,)37 b(automatic)d(dele)o(gation,)i(automatic)f(property)e
(creation,)k(proxies,)h(frame)n(w)o(orks,)f(and)d(automatic)g(resource)
g(lock-)0 3630 y(ing/synchronization.)0 3915 y Fk(3.4.4)100
b(Em)o(ulating)30 b(callab)n(le)f(objects)0 4114 y Fh(__call__)p
Fo(\()p Fq(self)12 b Fc([)p Fq(,)19 b(ar)m(gs...)12 b
Fc(])p Fo(\))208 4214 y Ft(Called)27 b(when)g(the)h(instance)f(is)h
(\223called\224)f(as)h(a)g(function;)h(if)f(this)g(method)e(is)i
(de\002ned,)g Fq(x)p Fo(\(arg1,)49 b(arg2,)g(...\))e
Ft(is)28 b(a)208 4314 y(shorthand)18 b(for)h Fq(x)p Fo
(.__call__\(arg1,)47 b(arg2,)i(...\))p Ft(.)0 4598 y
Fk(3.4.5)100 b(Em)o(ulating)30 b(container)f(types)0
4801 y Ft(The)f(follo)n(wing)f(methods)h(can)g(be)h(de\002ned)e(to)i
(implement)f(container)f(objects.)50 b(Containers)27
b(usually)i(are)f(sequences)g(\(such)g(as)0 4901 y(lists)h(or)e
(tuples\))g(or)g(mappings)e(\(lik)o(e)i(dictionaries\),)h(b)n(ut)f(can)
g(represent)f(other)h(containers)f(as)i(well.)47 b(The)27
b(\002rst)h(set)g(of)f(methods)0 5001 y(is)j(used)e(either)g(to)h
(emulate)f(a)i(sequence)d(or)i(to)f(emulate)h(a)g(mapping;)i(the)e(dif)
n(ference)d(is)k(that)f(for)f(a)h(sequence,)g(the)g(allo)n(w)o(able)0
5100 y(k)o(e)o(ys)21 b(should)g(be)h(the)g(inte)o(gers)f
Fq(k)j Ft(for)d(which)g Fo(0)50 b(<=)f Fq(k)i Fo(<)f
Fq(N)28 b Ft(where)21 b Fq(N)27 b Ft(is)c(the)f(length)f(of)h(the)f
(sequence,)g(or)h(slice)g(objects,)g(which)0 5200 y(de\002ne)i(a)g
(range)f(of)h(items.)37 b(\(F)o(or)24 b(backw)o(ards)e(compatibility)-5
b(,)23 b(the)h(method)f Fo(__getslice__\(\))f Ft(\(see)i(belo)n(w\))g
(can)g(also)g(be)g(de-)0 5299 y(\002ned)19 b(to)h(handle)f(simple,)h(b)
n(ut)g(not)f(e)o(xtended)f(slices.\))25 b(It)20 b(is)h(also)f
(recommended)d(that)j(mappings)e(pro)o(vide)g(the)i(methods)e
Fo(keys\(\))p Ft(,)0 5399 y Fo(values\(\))p Ft(,)34 b
Fo(items\(\))p Ft(,)f Fo(has_key\(\))p Ft(,)h Fo(get\(\))p
Ft(,)g Fo(clear\(\))p Ft(,)g Fo(setdefault\(\))p Ft(,)e
Fo(iterkeys\(\))p Ft(,)h Fo(itervalues\(\))p Ft(,)p 0
5549 3901 4 v 0 5649 a Fp(3.4.)52 b(Special)24 b(method)g(names)2774
b(27)p eop end
%%Page: 28 34
TeXDict begin 28 33 bop 0 83 a Fo(iteritems\(\))p Ft(,)25
b Fo(pop\(\))p Ft(,)g Fo(popitem\(\))p Ft(,)g Fo(copy\(\))p
Ft(,)h(and)e Fo(update\(\))g Ft(beha)n(ving)g(similar)h(to)g(those)g
(for)f(Python')-5 b(s)25 b(standard)0 183 y(dictionary)c(objects.)34
b(The)23 b Fo(UserDict)f Ft(module)g(pro)o(vides)g(a)h
Fo(DictMixin)f Ft(class)i(to)g(help)f(create)g(those)g(methods)f(from)g
(a)h(base)0 282 y(set)30 b(of)e Fo(__getitem__\(\))p
Ft(,)h Fo(__setitem__\(\))p Ft(,)f Fo(__delitem__\(\))p
Ft(,)h(and)f Fo(keys\(\))p Ft(.)50 b(Mutable)28 b(sequences)g(should)g
(pro-)0 382 y(vide)21 b(methods)f Fo(append\(\))p Ft(,)h
Fo(count\(\))p Ft(,)f Fo(index\(\))p Ft(,)h Fo(extend\(\))p
Ft(,)g Fo(insert\(\))p Ft(,)f Fo(pop\(\))p Ft(,)h Fo(remove\(\))p
Ft(,)g Fo(reverse\(\))f Ft(and)0 482 y Fo(sort\(\))p
Ft(,)k(lik)o(e)g(Python)f(standard)f(list)j(objects.)36
b(Finally)-5 b(,)23 b(sequence)g(types)h(should)e(implement)h(addition)
g(\(meaning)e(concatena-)0 581 y(tion\))28 b(and)g(multiplication)f
(\(meaning)f(repetition\))h(by)h(de\002ning)g(the)g(methods)f
Fo(__add__\(\))p Ft(,)j Fo(__radd__\(\))p Ft(,)f Fo(__iadd__-)0
681 y(\(\))p Ft(,)d Fo(__mul__\(\))p Ft(,)f Fo(__rmul__\(\))f
Ft(and)h Fo(__imul__\(\))f Ft(described)f(belo)n(w;)k(the)o(y)e(should)
f(not)h(de\002ne)f Fo(__coerce__\(\))g Ft(or)0 780 y(other)c(numerical)
g(operators.)25 b(It)c(is)h(recommended)c(that)j(both)f(mappings)g(and)
g(sequences)g(implement)g(the)h Fo(__contains__\(\))0
880 y Ft(method)27 b(to)i(allo)n(w)g(ef)n(\002cient)f(use)h(of)g(the)f
Fo(in)h Ft(operator;)i(for)d(mappings,)i Fo(in)e Ft(should)g(be)h(equi)
n(v)n(alent)e(of)h Fo(has_key\(\))p Ft(;)k(for)c(se-)0
980 y(quences,)19 b(it)h(should)f(search)h(through)d(the)j(v)n(alues.)
25 b(It)20 b(is)h(further)d(recommended)f(that)j(both)f(mappings)f(and)
i(sequences)f(implement)0 1079 y(the)k Fo(__iter__\(\))e
Ft(method)g(to)i(allo)n(w)g(ef)n(\002cient)f(iteration)g(through)f(the)
h(container;)h(for)f(mappings,)g Fo(__iter__\(\))f Ft(should)h(be)0
1179 y(the)e(same)h(as)f Fo(iterkeys\(\))p Ft(;)f(for)h(sequences,)f
(it)i(should)e(iterate)h(through)e(the)j(v)n(alues.)0
1326 y Fh(__len__)p Fo(\()p Fq(self)12 b Fo(\))208 1425
y Ft(Called)31 b(to)f(implement)g(the)g(b)n(uilt-in)g(function)f
Fo(len\(\))p Ft(.)56 b(Should)30 b(return)f(the)i(length)e(of)i(the)f
(object,)j(an)d(inte)o(ger)g Fo(>=)h Ft(0.)208 1525 y(Also,)23
b(an)g(object)f(that)h(doesn')o(t)e(de\002ne)h(a)h Fo(__nonzero__\(\))e
Ft(method)h(and)g(whose)g Fo(__len__\(\))g Ft(method)f(returns)h(zero)
208 1625 y(is)f(considered)d(to)i(be)h(f)o(alse)f(in)h(a)f(Boolean)g
(conte)o(xt.)0 1772 y Fh(__getitem__)p Fo(\()p Fq(self)o(,)f(k)o(e)n(y)
p Fo(\))208 1871 y Ft(Called)28 b(to)g(implement)f(e)n(v)n(aluation)f
(of)i Fq(self)12 b Fo([)p Fq(k)o(e)n(y)p Fo(])p Ft(.)49
b(F)o(or)27 b(sequence)g(types,)j(the)e(accepted)f(k)o(e)o(ys)h(should)
f(be)h(inte)o(gers)f(and)208 1971 y(slice)22 b(objects.)29
b(Note)22 b(that)g(the)f(special)h(interpretation)e(of)h(ne)o(gati)n(v)
o(e)f(inde)o(x)o(es)g(\(if)i(the)g(class)g(wishes)h(to)e(emulate)h(a)g
(sequence)208 2070 y(type\))h(is)i(up)f(to)h(the)f Fo(__getitem__\(\))e
Ft(method.)36 b(If)25 b Fq(k)o(e)n(y)f Ft(is)h(of)f(an)g(inappropriate)
e(type,)i Fo(TypeError)g Ft(may)f(be)i(raised;)208 2170
y(if)j(of)g(a)h(v)n(alue)f(outside)g(the)g(set)h(of)f(inde)o(x)o(es)g
(for)f(the)i(sequence)e(\(after)h(an)o(y)f(special)i(interpretation)d
(of)i(ne)o(gati)n(v)o(e)f(v)n(alues\),)208 2270 y Fo(IndexError)18
b Ft(should)g(be)i(raised.)k(F)o(or)19 b(mapping)f(types,)h(if)h
Fq(k)o(e)n(y)f Ft(is)h(missing)g(\(not)e(in)i(the)g(container\),)d
Fo(KeyError)i Ft(should)208 2369 y(be)28 b(raised.)50
b Fr(Note:)42 b Fo(for)28 b Ft(loops)g(e)o(xpect)g(that)h(an)f
Fo(IndexError)g Ft(will)h(be)g(raised)f(for)g(ille)o(gal)g(inde)o(x)o
(es)g(to)h(allo)n(w)f(proper)208 2469 y(detection)19
b(of)h(the)g(end)f(of)h(the)h(sequence.)0 2616 y Fh(__setitem__)p
Fo(\()p Fq(self)o(,)e(k)o(e)n(y)-5 b(,)20 b(value)p Fo(\))208
2715 y Ft(Called)31 b(to)h(implement)f(assignment)f(to)i
Fq(self)12 b Fo([)p Fq(k)o(e)n(y)p Fo(])p Ft(.)59 b(Same)32
b(note)f(as)h(for)f Fo(__getitem__\(\))p Ft(.)57 b(This)32
b(should)f(only)g(be)208 2815 y(implemented)17 b(for)i(mappings)f(if)i
(the)g(objects)f(support)f(changes)h(to)h(the)f(v)n(alues)h(for)f(k)o
(e)o(ys,)g(or)g(if)h(ne)n(w)f(k)o(e)o(ys)h(can)f(be)h(added,)e(or)208
2915 y(for)h(sequences)h(if)g(elements)g(can)h(be)f(replaced.)k(The)c
(same)h(e)o(xceptions)d(should)i(be)g(raised)g(for)g(improper)e
Fq(k)o(e)n(y)i Ft(v)n(alues)g(as)h(for)208 3014 y(the)f
Fo(__getitem__\(\))e Ft(method.)0 3161 y Fh(__delitem__)p
Fo(\()p Fq(self)o(,)h(k)o(e)n(y)p Fo(\))208 3261 y Ft(Called)29
b(to)g(implement)f(deletion)h(of)f Fq(self)12 b Fo([)p
Fq(k)o(e)n(y)p Fo(])p Ft(.)52 b(Same)29 b(note)g(as)h(for)f
Fo(__getitem__\(\))p Ft(.)50 b(This)29 b(should)f(only)h(be)g(im-)208
3360 y(plemented)24 b(for)h(mappings)g(if)h(the)g(objects)f(support)g
(remo)o(v)n(al)f(of)i(k)o(e)o(ys,)h(or)e(for)h(sequences)f(if)h
(elements)f(can)h(be)g(remo)o(v)o(ed)208 3460 y(from)18
b(the)h(sequence.)k(The)c(same)g(e)o(xceptions)e(should)h(be)h(raised)g
(for)g(improper)e Fq(k)o(e)n(y)i Ft(v)n(alues)f(as)i(for)e(the)h
Fo(__getitem__\(\))208 3560 y Ft(method.)0 3707 y Fh(__iter__)p
Fo(\()p Fq(self)12 b Fo(\))208 3806 y Ft(This)27 b(method)f(is)j
(called)e(when)g(an)g(iterator)g(is)h(required)e(for)h(a)h(container)-5
b(.)46 b(This)27 b(method)f(should)h(return)f(a)i(ne)n(w)f(iterator)208
3906 y(object)22 b(that)h(can)g(iterate)h(o)o(v)o(er)d(all)j(the)f
(objects)g(in)h(the)f(container)-5 b(.)33 b(F)o(or)22
b(mappings,)h(it)g(should)g(iterate)g(o)o(v)o(er)f(the)h(k)o(e)o(ys)g
(of)g(the)208 4005 y(container)m(,)18 b(and)h(should)g(also)i(be)f
(made)g(a)n(v)n(ailable)f(as)i(the)g(method)d Fo(iterkeys\(\))p
Ft(.)208 4138 y(Iterator)c(objects)h(also)g(need)g(to)g(implement)f
(this)i(method;)g(the)o(y)e(are)h(required)f(to)h(return)f(themselv)o
(es.)23 b(F)o(or)15 b(more)f(information)208 4238 y(on)19
b(iterator)h(objects,)g(see)g(\223Iterator)f(T)-7 b(ypes\224)20
b(in)h(the)f Fq(Python)f(Libr)o(ary)h(Refer)m(ence)p
Ft(.)0 4385 y(The)31 b(membership)f(test)j(operators)d(\()p
Fo(in)h Ft(and)g Fo(not)50 b(in)p Ft(\))31 b(are)h(normally)e
(implemented)f(as)k(an)e(iteration)g(through)f(a)i(sequence.)0
4484 y(Ho)n(we)n(v)o(er)m(,)17 b(container)h(objects)h(can)g(supply)f
(the)i(follo)n(wing)d(special)i(method)f(with)i(a)f(more)g(ef)n
(\002cient)g(implementation,)e(which)h(also)0 4584 y(does)i(not)g
(require)f(the)h(object)g(be)g(a)g(sequence.)0 4731 y
Fh(__contains__)p Fo(\()p Fq(self)o(,)f(item)p Fo(\))208
4831 y Ft(Called)31 b(to)g(implement)f(membership)f(test)j(operators.)
56 b(Should)30 b(return)g(true)h(if)g Fq(item)h Ft(is)g(in)f
Fq(self)12 b Ft(,)34 b(f)o(alse)e(otherwise.)57 b(F)o(or)208
4930 y(mapping)18 b(objects,)i(this)g(should)f(consider)h(the)g(k)o(e)o
(ys)g(of)f(the)i(mapping)d(rather)h(than)h(the)g(v)n(alues)g(or)g(the)g
(k)o(e)o(y-item)f(pairs.)p 0 5549 3901 4 v 0 5649 a Fp(28)2944
b(Chapter)24 b(3.)52 b(Data)23 b(model)p eop end
%%Page: 29 35
TeXDict begin 29 34 bop 0 83 a Fk(3.4.6)100 b(Additional)30
b(methods)f(f)m(or)f(em)o(ulation)i(of)d(sequence)j(types)0
286 y Ft(The)24 b(follo)n(wing)f(optional)h(methods)f(can)i(be)f
(de\002ned)g(to)h(further)e(emulate)h(sequence)g(objects.)38
b(Immutable)23 b(sequences)h(methods)0 386 y(should)19
b(at)i(most)f(only)f(de\002ne)h Fo(__getslice__\(\))p
Ft(;)e(mutable)i(sequences)f(might)g(de\002ne)h(all)h(three)f(methods.)
0 532 y Fh(__getslice__)p Fo(\()p Fq(self)o(,)f(i,)h(j)p
Fo(\))208 632 y Fr(Depr)o(ecated)f(since)i(r)o(elease)e(2.0.)24
b Ft(Support)19 b(slice)i(objects)f(as)h(parameters)e(to)h(the)g
Fo(__getitem__\(\))f Ft(method.)208 765 y(Called)i(to)g(implement)f(e)n
(v)n(aluation)g(of)h Fq(self)12 b Fo([)p Fq(i)p Fo(:)p
Fq(j)p Fo(])p Ft(.)28 b(The)21 b(returned)e(object)i(should)f(be)h(of)g
(the)g(same)h(type)f(as)g Fq(self)12 b Ft(.)29 b(Note)21
b(that)208 865 y(missing)k Fq(i)h Ft(or)e Fq(j)i Ft(in)g(the)f(slice)h
(e)o(xpression)d(are)j(replaced)e(by)g(zero)h(or)g Fo(sys.maxint)p
Ft(,)g(respecti)n(v)o(ely)-5 b(.)38 b(If)25 b(ne)o(gati)n(v)o(e)e(inde)
o(x)o(es)208 964 y(are)29 b(used)g(in)h(the)f(slice,)k(the)c(length)g
(of)g(the)h(sequence)e(is)i(added)f(to)g(that)h(inde)o(x.)51
b(If)30 b(the)f(instance)g(does)h(not)f(implement)208
1064 y(the)d Fo(__len__\(\))f Ft(method,)h(an)g Fo(AttributeError)e
Ft(is)j(raised.)42 b(No)26 b(guarantee)e(is)j(made)f(that)g(inde)o(x)o
(es)f(adjusted)g(this)208 1163 y(w)o(ay)h(are)g(not)g(still)i(ne)o
(gati)n(v)o(e.)41 b(Inde)o(x)o(es)25 b(which)h(are)g(greater)g(than)f
(the)i(length)e(of)h(the)h(sequence)e(are)h(not)g(modi\002ed.)43
b(If)26 b(no)208 1263 y Fo(__getslice__\(\))18 b Ft(is)j(found,)d(a)j
(slice)g(object)e(is)i(created)f(instead,)g(and)f(passed)h(to)h
Fo(__getitem__\(\))d Ft(instead.)0 1410 y Fh(__setslice__)p
Fo(\()p Fq(self)o(,)h(i,)h(j,)h(sequence)p Fo(\))208
1510 y Ft(Called)f(to)g(implement)f(assignment)h(to)g
Fq(self)12 b Fo([)p Fq(i)p Fo(:)p Fq(j)p Fo(])p Ft(.)26
b(Same)20 b(notes)g(for)f Fq(i)i Ft(and)f Fq(j)h Ft(as)g(for)e
Fo(__getslice__\(\))p Ft(.)208 1642 y(This)f(method)e(is)j(deprecated.)
k(If)18 b(no)f Fo(__setslice__\(\))f Ft(is)j(found,)e(or)h(for)f(e)o
(xtended)f(slicing)i(of)g(the)g(form)f Fq(self)12 b Fo([)p
Fq(i)p Fo(:)p Fq(j)p Fo(:)p Fq(k)q Fo(])p Ft(,)208 1742
y(a)20 b(slice)h(object)f(is)h(created,)e(and)h(passed)g(to)g
Fo(__setitem__\(\))p Ft(,)e(instead)i(of)g Fo(__setslice__\(\))e
Ft(being)h(called.)0 1889 y Fh(__delslice__)p Fo(\()p
Fq(self)o(,)g(i,)h(j)p Fo(\))208 1988 y Ft(Called)j(to)g(implement)e
(deletion)h(of)g Fq(self)12 b Fo([)p Fq(i)p Fo(:)p Fq(j)p
Fo(])p Ft(.)34 b(Same)22 b(notes)h(for)f Fq(i)h Ft(and)g
Fq(j)g Ft(as)h(for)e Fo(__getslice__\(\))p Ft(.)30 b(This)23
b(method)f(is)208 2088 y(deprecated.)27 b(If)22 b(no)f
Fo(__delslice__\(\))f Ft(is)i(found,)e(or)i(for)f(e)o(xtended)f
(slicing)h(of)h(the)f(form)g Fq(self)12 b Fo([)p Fq(i)p
Fo(:)p Fq(j)p Fo(:)p Fq(k)q Fo(])p Ft(,)23 b(a)f(slice)g(object)208
2188 y(is)f(created,)e(and)h(passed)g(to)g Fo(__delitem__\(\))p
Ft(,)e(instead)i(of)g Fo(__delslice__\(\))e Ft(being)h(called.)0
2335 y(Notice)25 b(that)h(these)g(methods)e(are)i(only)f(in)m(v)n(ok)o
(ed)f(when)h(a)h(single)f(slice)h(with)g(a)g(single)g(colon)e(is)j
(used,)f(and)f(the)h(slice)g(method)f(is)0 2434 y(a)n(v)n(ailable.)k(F)
o(or)22 b(slice)g(operations)f(in)m(v)n(olving)e(e)o(xtended)h(slice)j
(notation,)d(or)i(in)g(absence)f(of)h(the)g(slice)g(methods,)f
Fo(__getitem_-)0 2534 y(_\(\))p Ft(,)f Fo(__setitem__\(\))e
Ft(or)i Fo(__delitem__\(\))f Ft(is)i(called)f(with)g(a)h(slice)g
(object)e(as)i(ar)o(gument.)0 2681 y(The)e(follo)n(wing)f(e)o(xample)g
(demonstrate)g(ho)n(w)h(to)g(mak)o(e)g(your)f(program)f(or)j(module)e
(compatible)g(with)h(earlier)g(v)o(ersions)g(of)g(Python)0
2780 y(\(assuming)k(that)h(methods)f Fo(__getitem__\(\))p
Ft(,)h Fo(__setitem__\(\))e Ft(and)i Fo(__delitem__\(\))e
Ft(support)h(slice)i(objects)f(as)h(ar)n(-)0 2880 y(guments\):)236
3118 y Fi(class)44 b(MyClass:)416 3209 y(...)416 3301
y(def)g(__getitem__\(self,)e(index\):)595 3392 y(...)416
3483 y(def)i(__setitem__\(self,)e(index,)i(value\):)595
3575 y(...)416 3666 y(def)g(__delitem__\(self,)e(index\):)595
3757 y(...)416 3940 y(if)i(sys.version_info)e(<)j(\(2,)f(0\):)595
4031 y(#)h(They)f(won't)g(be)g(defined)g(if)g(version)g(is)g(at)h
(least)f(2.0)g(final)595 4214 y(def)g(__getslice__\(self,)e(i,)j(j\):)
774 4305 y(return)f(self[max\(0,)f(i\):max\(0,)g(j\):])595
4397 y(def)h(__setslice__\(self,)e(i,)j(j,)f(seq\):)774
4488 y(self[max\(0,)f(i\):max\(0,)h(j\):])g(=)g(seq)595
4579 y(def)g(__delslice__\(self,)e(i,)j(j\):)774 4671
y(del)g(self[max\(0,)e(i\):max\(0,)g(j\):])416 4762 y(...)0
5049 y Ft(Note)19 b(the)h(calls)g(to)f Fo(max\(\))p Ft(;)g(these)h(are)
f(necessary)g(because)f(of)h(the)g(handling)f(of)h(ne)o(gati)n(v)o(e)e
(indices)i(before)f(the)h Fo(__)3402 5064 y(*)3452 5049
y(slice__\(\))0 5148 y Ft(methods)i(are)h(called.)31
b(When)22 b(ne)o(gati)n(v)o(e)f(inde)o(x)o(es)g(are)h(used,)g(the)g
Fo(__)2018 5163 y(*)2068 5148 y(item__\(\))f Ft(methods)g(recei)n(v)o
(e)g(them)h(as)h(pro)o(vided,)d(b)n(ut)j(the)0 5248 y
Fo(__)100 5263 y(*)150 5248 y(slice__\(\))k Ft(methods)h(get)g(a)h
(\223cook)o(ed\224)e(form)h(of)g(the)h(inde)o(x)f(v)n(alues.)50
b(F)o(or)28 b(each)g(ne)o(gati)n(v)o(e)f(inde)o(x)g(v)n(alue,)j(the)f
(length)f(of)0 5347 y(the)d(sequence)e(is)j(added)d(to)i(the)g(inde)o
(x)e(before)g(calling)i(the)f(method)g(\(which)f(may)h(still)i(result)f
(in)g(a)g(ne)o(gati)n(v)o(e)d(inde)o(x\);)k(this)f(is)h(the)p
0 5549 3901 4 v 0 5649 a Fp(3.4.)52 b(Special)24 b(method)g(names)2774
b(29)p eop end
%%Page: 30 36
TeXDict begin 30 35 bop 0 83 a Ft(customary)17 b(handling)h(of)g(ne)o
(gati)n(v)o(e)f(inde)o(x)o(es)h(by)g(the)h(b)n(uilt-in)g(sequence)f
(types,)g(and)h(the)g Fo(__)2717 98 y(*)2767 83 y(item__\(\))e
Ft(methods)h(are)h(e)o(xpected)0 183 y(to)j(do)f(this)h(as)g(well.)30
b(Ho)n(we)n(v)o(er)m(,)20 b(since)i(the)o(y)f(should)f(already)h(be)g
(doing)g(that,)h(ne)o(gati)n(v)o(e)d(inde)o(x)o(es)h(cannot)h(be)h
(passed)f(in;)i(the)o(y)e(must)0 282 y(be)i(constrained)d(to)j(the)g
(bounds)e(of)h(the)h(sequence)e(before)h(being)f(passed)i(to)g(the)f
Fo(__)2527 297 y(*)2577 282 y(item__\(\))f Ft(methods.)31
b(Calling)23 b Fo(max\(0,)0 382 y(i\))d Ft(con)m(v)o(eniently)d
(returns)j(the)g(proper)e(v)n(alue.)0 667 y Fk(3.4.7)100
b(Em)o(ulating)30 b(n)o(umer)q(ic)f(types)0 870 y Ft(The)22
b(follo)n(wing)e(methods)h(can)g(be)h(de\002ned)f(to)h(emulate)f
(numeric)g(objects.)29 b(Methods)21 b(corresponding)e(to)j(operations)e
(that)i(are)g(not)0 969 y(supported)17 b(by)i(the)g(particular)f(kind)h
(of)g(number)e(implemented)g(\(e.g.,)i(bitwise)g(operations)f(for)h
(non-inte)o(gral)d(numbers\))h(should)i(be)0 1069 y(left)h
(unde\002ned.)0 1216 y Fh(__add__)p Fo(\()p Fq(self)o(,)g(other)r
Fo(\))0 1315 y Fh(__sub__)p Fo(\()p Fq(self)o(,)g(other)r
Fo(\))0 1415 y Fh(__mul__)p Fo(\()p Fq(self)o(,)g(other)r
Fo(\))0 1515 y Fh(__floordiv__)p Fo(\()p Fq(self)o(,)f(other)r
Fo(\))0 1614 y Fh(__mod__)p Fo(\()p Fq(self)o(,)h(other)r
Fo(\))0 1714 y Fh(__divmod__)p Fo(\()p Fq(self)o(,)f(other)r
Fo(\))0 1814 y Fh(__pow__)p Fo(\()p Fq(self)o(,)h(other)r
Fc([)p Fq(,)f(modulo)12 b Fc(])p Fo(\))0 1913 y Fh(__lshift__)p
Fo(\()p Fq(self)o(,)19 b(other)r Fo(\))0 2013 y Fh(__rshift__)p
Fo(\()p Fq(self)o(,)g(other)r Fo(\))0 2112 y Fh(__and__)p
Fo(\()p Fq(self)o(,)h(other)r Fo(\))0 2212 y Fh(__xor__)p
Fo(\()p Fq(self)o(,)g(other)r Fo(\))0 2312 y Fh(__or__)p
Fo(\()p Fq(self)o(,)g(other)r Fo(\))208 2411 y Ft(These)i(methods)g
(are)h(called)f(to)h(implement)f(the)h(binary)e(arithmetic)h
(operations)f(\()p Fo(+)p Ft(,)j Fo(-)p Ft(,)2853 2426
y Fo(*)2903 2411 y Ft(,)g Fo(//)p Ft(,)f Fo(\045)p Ft(,)h
Fo(divmod\(\))p Ft(,)e Fo(pow\(\))p Ft(,)208 2526 y Fo(**)308
2511 y Ft(,)k Fo(<<)p Ft(,)h Fo(>>)p Ft(,)g Fo(&)p Ft(,)g
Fo(\210)p Ft(,)g Fo(|)p Ft(\).)41 b(F)o(or)25 b(instance,)i(to)e(e)n(v)
n(aluate)g(the)h(e)o(xpression)e Fq(x)p Fo(+)p Fq(y)p
Ft(,)j(where)d Fq(x)j Ft(is)f(an)g(instance)f(of)g(a)h(class)h(that)e
(has)208 2611 y(an)19 b Fo(__add__\(\))f Ft(method,)g
Fq(x)p Fo(.__add__\()p Fq(y)p Fo(\))g Ft(is)j(called.)j(The)19
b Fo(__divmod__\(\))f Ft(method)g(should)h(be)g(the)h(equi)n(v)n(alent)
d(to)208 2710 y(using)h Fo(__floordiv__\(\))g Ft(and)g
Fo(__mod__\(\))p Ft(;)h(it)h(should)e(not)h(be)g(related)g(to)h
Fo(__truediv__\(\))d Ft(\(described)h(belo)n(w\).)208
2810 y(Note)29 b(that)h Fo(__pow__\(\))f Ft(should)g(be)h(de\002ned)e
(to)i(accept)g(an)g(optional)e(third)h(ar)o(gument)f(if)i(the)g
(ternary)e(v)o(ersion)h(of)h(the)208 2909 y(b)n(uilt-in)19
b Fo(pow\(\))h Ft(function)e(is)k(to)e(be)g(supported.)208
3042 y(If)43 b(one)f(of)i(those)f(methods)f(does)h(not)g(support)f(the)
h(operation)f(with)h(the)g(supplied)g(ar)o(guments,)j(it)e(should)f
(return)208 3142 y Fo(NotImplemented)p Ft(.)0 3289 y
Fh(__div__)p Fo(\()p Fq(self)o(,)20 b(other)r Fo(\))0
3388 y Fh(__truediv__)p Fo(\()p Fq(self)o(,)f(other)r
Fo(\))208 3488 y Ft(The)j(di)n(vision)g(operator)f(\()p
Fo(/)p Ft(\))h(is)i(implemented)c(by)j(these)f(methods.)32
b(The)22 b Fo(__truediv__\(\))f Ft(method)g(is)j(used)e(when)g
Fo(_-)208 3588 y(_future__.division)i Ft(is)29 b(in)f(ef)n(fect,)h
(otherwise)e Fo(__div__\(\))f Ft(is)j(used.)47 b(If)28
b(only)f(one)g(of)g(these)h(tw)o(o)g(methods)f(is)208
3687 y(de\002ned,)18 b(the)j(object)e(will)i(not)f(support)f(di)n
(vision)g(in)i(the)f(alternate)f(conte)o(xt;)g Fo(TypeError)g
Ft(will)i(be)g(raised)f(instead.)0 3834 y Fh(__radd__)p
Fo(\()p Fq(self)o(,)f(other)r Fo(\))0 3934 y Fh(__rsub__)p
Fo(\()p Fq(self)o(,)g(other)r Fo(\))0 4033 y Fh(__rmul__)p
Fo(\()p Fq(self)o(,)g(other)r Fo(\))0 4133 y Fh(__rdiv__)p
Fo(\()p Fq(self)o(,)g(other)r Fo(\))0 4233 y Fh(__rtruediv__)p
Fo(\()p Fq(self)o(,)g(other)r Fo(\))0 4332 y Fh(__rfloordiv__)p
Fo(\()p Fq(self)o(,)f(other)r Fo(\))0 4432 y Fh(__rmod__)p
Fo(\()p Fq(self)o(,)h(other)r Fo(\))0 4532 y Fh(__rdivmod__)p
Fo(\()p Fq(self)o(,)g(other)r Fo(\))0 4631 y Fh(__rpow__)p
Fo(\()p Fq(self)o(,)g(other)r Fo(\))0 4731 y Fh(__rlshift__)p
Fo(\()p Fq(self)o(,)g(other)r Fo(\))0 4830 y Fh(__rrshift__)p
Fo(\()p Fq(self)o(,)g(other)r Fo(\))0 4930 y Fh(__rand__)p
Fo(\()p Fq(self)o(,)g(other)r Fo(\))0 5030 y Fh(__rxor__)p
Fo(\()p Fq(self)o(,)g(other)r Fo(\))0 5129 y Fh(__ror__)p
Fo(\()p Fq(self)o(,)h(other)r Fo(\))208 5229 y Ft(These)25
b(methods)g(are)g(called)h(to)g(implement)e(the)i(binary)e(arithmetic)h
(operations)f(\()p Fo(+)p Ft(,)j Fo(-)p Ft(,)2889 5244
y Fo(*)2939 5229 y Ft(,)g Fo(/)p Ft(,)g Fo(\045)p Ft(,)g
Fo(divmod\(\))p Ft(,)f Fo(pow\(\))p Ft(,)208 5344 y Fo(**)308
5329 y Ft(,)19 b Fo(<<)p Ft(,)g Fo(>>)p Ft(,)g Fo(&)p
Ft(,)g Fo(\210)p Ft(,)g Fo(|)p Ft(\))g(with)g(re\003ected)g(\(sw)o
(apped\))e(operands.)23 b(These)c(functions)e(are)i(only)f(called)h(if)
g(the)g(left)g(operand)e(does)p 0 5549 3901 4 v 0 5649
a Fp(30)2944 b(Chapter)24 b(3.)52 b(Data)23 b(model)p
eop end
%%Page: 31 37
TeXDict begin 31 36 bop 208 83 a Ft(not)23 b(support)f(the)h
(corresponding)d(operation)i(and)h(the)g(operands)f(are)i(of)f(dif)n
(ferent)f(types.)2890 53 y Fg(3)2958 83 y Ft(F)o(or)h(instance,)g(to)h
(e)n(v)n(aluate)f(the)208 183 y(e)o(xpression)16 b Fq(x)p
Fo(-)p Fq(y)p Ft(,)j(where)f Fq(y)h Ft(is)g(an)g(instance)f(of)g(a)h
(class)g(that)g(has)g(an)f Fo(__rsub__\(\))f Ft(method,)g
Fq(y)p Fo(.__rsub__\()p Fq(x)p Fo(\))g Ft(is)j(called)208
282 y(if)g Fq(x)p Fo(.__sub__\()p Fq(y)p Fo(\))f Ft(returns)g
Fq(NotImplemented)r Ft(.)208 415 y(Note)e(that)g(ternary)f
Fo(pow\(\))h Ft(will)i(not)e(try)g(calling)g Fo(__rpow__\(\))f
Ft(\(the)h(coercion)f(rules)h(w)o(ould)g(become)f(too)h(complicated\).)
208 548 y Fr(Note:)44 b Ft(If)31 b(the)f(right)g(operand')-5
b(s)29 b(type)h(is)h(a)g(subclass)g(of)f(the)g(left)h(operand')-5
b(s)29 b(type)h(and)f(that)i(subclass)g(pro)o(vides)d(the)j(re-)208
648 y(\003ected)18 b(method)f(for)h(the)h(operation,)d(this)k(method)d
(will)i(be)f(called)h(before)e(the)i(left)f(operand')-5
b(s)17 b(non-re\003ected)f(method.)23 b(This)208 747
y(beha)n(vior)18 b(allo)n(ws)j(subclasses)f(to)h(o)o(v)o(erride)c
(their)j(ancestors')g(operations.)0 894 y Fh(__iadd__)p
Fo(\()p Fq(self)o(,)f(other)r Fo(\))0 994 y Fh(__isub__)p
Fo(\()p Fq(self)o(,)g(other)r Fo(\))0 1093 y Fh(__imul__)p
Fo(\()p Fq(self)o(,)g(other)r Fo(\))0 1193 y Fh(__idiv__)p
Fo(\()p Fq(self)o(,)g(other)r Fo(\))0 1293 y Fh(__itruediv__)p
Fo(\()p Fq(self)o(,)g(other)r Fo(\))0 1392 y Fh(__ifloordiv__)p
Fo(\()p Fq(self)o(,)f(other)r Fo(\))0 1492 y Fh(__imod__)p
Fo(\()p Fq(self)o(,)h(other)r Fo(\))0 1591 y Fh(__ipow__)p
Fo(\()p Fq(self)o(,)g(other)r Fc([)p Fq(,)h(modulo)12
b Fc(])p Fo(\))0 1691 y Fh(__ilshift__)p Fo(\()p Fq(self)o(,)19
b(other)r Fo(\))0 1791 y Fh(__irshift__)p Fo(\()p Fq(self)o(,)g(other)r
Fo(\))0 1890 y Fh(__iand__)p Fo(\()p Fq(self)o(,)g(other)r
Fo(\))0 1990 y Fh(__ixor__)p Fo(\()p Fq(self)o(,)g(other)r
Fo(\))0 2090 y Fh(__ior__)p Fo(\()p Fq(self)o(,)h(other)r
Fo(\))208 2189 y Ft(These)i(methods)g(are)g(called)h(to)f(implement)g
(the)h(augmented)d(arithmetic)i(operations)f(\()p Fo(+=)p
Ft(,)i Fo(-=)p Ft(,)3103 2204 y Fo(*)3153 2189 y(=)p
Ft(,)g Fo(/=)p Ft(,)h Fo(//=)p Ft(,)f Fo(\045=)p Ft(,)3730
2204 y Fo(**)3830 2189 y(=)p Ft(,)208 2289 y Fo(<<=)p
Ft(,)18 b Fo(>>=)p Ft(,)h Fo(&=)p Ft(,)g Fo(\210=)p Ft(,)g
Fo(|=)p Ft(\).)25 b(These)18 b(methods)g(should)g(attempt)g(to)h(do)g
(the)f(operation)f(in-place)h(\(modifying)e Fq(self)c
Ft(\))19 b(and)g(return)208 2388 y(the)25 b(result)h(\(which)f(could)g
(be,)i(b)n(ut)f(does)g(not)f(ha)n(v)o(e)g(to)h(be,)h
Fq(self)12 b Ft(\).)43 b(If)26 b(a)g(speci\002c)g(method)e(is)j(not)f
(de\002ned,)g(the)g(augmented)208 2488 y(operation)15
b(f)o(alls)k(back)e(to)h(the)g(normal)e(methods.)23 b(F)o(or)18
b(instance,)f(to)h(e)n(v)n(aluate)f(the)h(e)o(xpression)e
Fq(x)p Fo(+=)p Fq(y)p Ft(,)i(where)f Fq(x)i Ft(is)f(an)g(instance)208
2588 y(of)27 b(a)h(class)g(that)g(has)g(an)g Fo(__iadd__\(\))e
Ft(method,)i Fq(x)p Fo(.__iadd__\()p Fq(y)p Fo(\))e Ft(is)i(called.)47
b(If)28 b Fq(x)g Ft(is)h(an)e(instance)h(of)f(a)h(class)g(that)208
2687 y(does)23 b(not)g(de\002ne)g(a)g Fo(__iadd__\(\))f
Ft(method,)h Fq(x)p Fo(.__add__\()p Fq(y)p Fo(\))f Ft(and)h
Fq(y)p Fo(.__radd__\()p Fq(x)p Fo(\))f Ft(are)h(considered,)f(as)i
(with)g(the)208 2787 y(e)n(v)n(aluation)18 b(of)i Fq(x)p
Fo(+)p Fq(y)p Ft(.)0 2934 y Fh(__neg__)p Fo(\()p Fq(self)12
b Fo(\))0 3033 y Fh(__pos__)p Fo(\()p Fq(self)g Fo(\))0
3133 y Fh(__abs__)p Fo(\()p Fq(self)g Fo(\))0 3233 y
Fh(__invert__)p Fo(\()p Fq(self)g Fo(\))208 3332 y Ft(Called)20
b(to)g(implement)f(the)i(unary)d(arithmetic)i(operations)e(\()p
Fo(-)p Ft(,)i Fo(+)p Ft(,)h Fo(abs\(\))e Ft(and)h Fo(\230)p
Ft(\).)0 3479 y Fh(__complex__)p Fo(\()p Fq(self)12 b
Fo(\))0 3579 y Fh(__int__)p Fo(\()p Fq(self)g Fo(\))0
3678 y Fh(__long__)p Fo(\()p Fq(self)g Fo(\))0 3778 y
Fh(__float__)p Fo(\()p Fq(self)g Fo(\))208 3878 y Ft(Called)27
b(to)g(implement)f(the)h(b)n(uilt-in)g(functions)f Fo(complex\(\))p
Ft(,)h Fo(int\(\))p Ft(,)h Fo(long\(\))p Ft(,)h(and)d
Fo(float\(\))p Ft(.)45 b(Should)26 b(return)g(a)208 3977
y(v)n(alue)19 b(of)h(the)g(appropriate)e(type.)0 4124
y Fh(__oct__)p Fo(\()p Fq(self)12 b Fo(\))0 4224 y Fh(__hex__)p
Fo(\()p Fq(self)g Fo(\))208 4323 y Ft(Called)20 b(to)g(implement)f(the)
i(b)n(uilt-in)e(functions)g Fo(oct\(\))h Ft(and)f Fo(hex\(\))p
Ft(.)25 b(Should)19 b(return)g(a)i(string)e(v)n(alue.)0
4470 y Fh(__index__)p Fo(\()p Fq(self)12 b Fo(\))208
4570 y Ft(Called)21 b(to)h(implement)e Fo(operator.index\(\))p
Ft(.)26 b(Also)c(called)f(whene)n(v)o(er)f(Python)g(needs)h(an)g(inte)o
(ger)g(object)f(\(such)h(as)h(in)208 4670 y(slicing\).)i(Must)d(return)
e(an)h(inte)o(ger)f(\(int)h(or)g(long\).)49 b(Ne)n(w)21
b(in)f(v)o(ersion)f(2.5.)0 4816 y Fh(__coerce__)p Fo(\()p
Fq(self)o(,)g(other)r Fo(\))208 4916 y Ft(Called)f(to)g(implement)f
(\223mix)o(ed-mode\224)e(numeric)h(arithmetic.)24 b(Should)16
b(either)i(return)f(a)h(2-tuple)f(containing)f Fq(self)31
b Ft(and)18 b Fq(other)208 5016 y Ft(con)m(v)o(erted)i(to)j(a)g(common)
e(numeric)g(type,)i(or)g Fo(None)f Ft(if)i(con)m(v)o(ersion)c(is)j
(impossible.)33 b(When)22 b(the)h(common)e(type)i(w)o(ould)f(be)208
5115 y(the)f(type)g(of)g Fo(other)p Ft(,)g(it)h(is)g(suf)n(\002cient)f
(to)g(return)f Fo(None)p Ft(,)h(since)h(the)f(interpreter)f(will)i
(also)f(ask)h(the)f(other)g(object)f(to)i(attempt)p 0
5186 1560 4 v 90 5242 a Ff(3)120 5265 y Fl(F)o(or)16
b(operands)i(of)e(the)h(same)g(type,)g(it)g(is)f(assumed)h(that)g(if)g
(the)g(non-re\003ected)j(method)d(\(such)g(as)f Fb(__add__\(\))p
Fl(\))f(f)o(ails)j(the)f(operation)i(is)d(not)h(supported,)h(which)0
5344 y(is)f(why)g(the)g(re\003ected)j(method)d(is)g(not)h(called.)p
0 5549 3901 4 v 0 5649 a Fp(3.4.)52 b(Special)24 b(method)g(names)2774
b(31)p eop end
%%Page: 32 38
TeXDict begin 32 37 bop 208 83 a Ft(a)28 b(coercion)f(\(b)n(ut)h
(sometimes,)i(if)f(the)f(implementation)e(of)i(the)h(other)e(type)h
(cannot)f(be)i(changed,)f(it)h(is)g(useful)f(to)h(do)f(the)208
183 y(con)m(v)o(ersion)17 b(to)j(the)h(other)e(type)h(here\).)k(A)c
(return)f(v)n(alue)h(of)g Fo(NotImplemented)e Ft(is)j(equi)n(v)n(alent)
e(to)h(returning)e Fo(None)p Ft(.)0 467 y Fk(3.4.8)100
b(Coercion)29 b(r)q(ules)0 669 y Ft(This)c(section)f(used)g(to)g
(document)f(the)h(rules)g(for)g(coercion.)36 b(As)25
b(the)g(language)d(has)j(e)n(v)n(olv)o(ed,)f(the)g(coercion)f(rules)h
(ha)n(v)o(e)g(become)0 769 y(hard)30 b(to)g(document)f(precisely;)35
b(documenting)27 b(what)k(one)f(v)o(ersion)f(of)h(one)g(particular)g
(implementation)e(does)i(is)i(undesirable.)0 869 y(Instead,)19
b(here)h(are)g(some)g(informal)f(guidelines)g(re)o(garding)e(coercion.)
23 b(In)d(Python)f(3.0,)h(coercion)e(will)j(not)f(be)g(supported.)125
1093 y Fs(\017)41 b Ft(If)17 b(the)g(left)h(operand)d(of)i(a)h(\045)g
(operator)d(is)j(a)g(string)f(or)g(Unicode)f(object,)h(no)g(coercion)f
(tak)o(es)h(place)g(and)g(the)h(string)e(formatting)208
1193 y(operation)i(is)j(in)m(v)n(ok)o(ed)d(instead.)125
1356 y Fs(\017)41 b Ft(It)21 b(is)i(no)e(longer)g(recommended)d(to)k
(de\002ne)f(a)h(coercion)e(operation.)28 b(Mix)o(ed-mode)19
b(operations)h(on)h(types)g(that)h(don')o(t)e(de\002ne)208
1456 y(coercion)e(pass)j(the)f(original)f(ar)o(guments)f(to)j(the)f
(operation.)125 1620 y Fs(\017)41 b Ft(Ne)n(w-style)26
b(classes)i(\(those)e(deri)n(v)o(ed)e(from)i Fo(object)p
Ft(\))g(ne)n(v)o(er)f(in)m(v)n(ok)o(e)g(the)i Fo(__coerce__\(\))e
Ft(method)g(in)i(response)e(to)i(a)208 1719 y(binary)18
b(operator;)h(the)h(only)f(time)i Fo(__coerce__\(\))d
Ft(is)j(in)m(v)n(ok)o(ed)e(is)i(when)f(the)g(b)n(uilt-in)f(function)g
Fo(coerce\(\))g Ft(is)i(called.)125 1883 y Fs(\017)41
b Ft(F)o(or)24 b(most)h(intents)f(and)g(purposes,)h(an)f(operator)f
(that)i(returns)f Fo(NotImplemented)e Ft(is)k(treated)e(the)h(same)f
(as)i(one)e(that)h(is)208 1983 y(not)19 b(implemented)g(at)h(all.)125
2147 y Fs(\017)41 b Ft(Belo)n(w)-5 b(,)19 b Fo(__op__\(\))g
Ft(and)h Fo(__rop__\(\))f Ft(are)h(used)g(to)g(signify)f(the)i(generic)
e(method)f(names)i(corresponding)d(to)j(an)g(opera-)208
2246 y(tor;)g Fo(__iop__\(\))g Ft(is)h(used)g(for)f(the)g
(corresponding)d(in-place)j(operator)-5 b(.)25 b(F)o(or)20
b(e)o(xample,)f(for)h(the)g(operator)f(`)p Fo(+)p Ft(',)h
Fo(__add_-)208 2346 y(_\(\))f Ft(and)g Fo(__radd__\(\))g
Ft(are)g(used)h(for)f(the)g(left)h(and)f(right)h(v)n(ariant)e(of)i(the)
f(binary)g(operator)m(,)e(and)i Fo(__iadd__\(\))g Ft(for)g(the)208
2446 y(in-place)g(v)n(ariant.)125 2609 y Fs(\017)41 b
Ft(F)o(or)26 b(objects)h Fq(x)h Ft(and)e Fq(y)p Ft(,)j(\002rst)e
Fq(x)p Fo(.__op__\()p Fq(y)p Fo(\))f Ft(is)i(tried.)45
b(If)27 b(this)h(is)f(not)g(implemented)e(or)i(returns)f
Fo(NotImplemented)p Ft(,)208 2709 y Fq(y)p Fo(.__rop__\()p
Fq(x)p Fo(\))e Ft(is)i(tried.)40 b(If)26 b(this)f(is)i(also)f(not)f
(implemented)e(or)i(returns)g Fo(NotImplemented)p Ft(,)f(a)i
Fo(TypeError)e Ft(e)o(x-)208 2809 y(ception)19 b(is)i(raised.)k(But)20
b(see)h(the)f(follo)n(wing)f(e)o(xception:)125 2972 y
Fs(\017)41 b Ft(Exception)25 b(to)j(the)g(pre)n(vious)e(item:)40
b(if)28 b(the)g(left)g(operand)d(is)k(an)f(instance)f(of)g(a)h(b)n
(uilt-in)f(type)h(or)f(a)h(ne)n(w-style)f(class,)j(and)208
3072 y(the)21 b(right)g(operand)e(is)j(an)f(instance)g(of)g(a)h(proper)
d(subclass)j(of)f(that)g(type)g(or)g(class)i(and)d(o)o(v)o(errides)g
(the)h(base')-5 b(s)22 b Fo(__rop__\(\))208 3172 y Ft(method,)c(the)i
(right)g(operand')-5 b(s)18 b Fo(__rop__\(\))i Ft(method)e(is)j(tried)f
Fq(befor)m(e)g Ft(the)g(left)h(operand')-5 b(s)18 b Fo(__op__\(\))i
Ft(method.)208 3303 y(This)f(is)h(done)e(so)h(that)h(a)f(subclass)g
(can)g(completely)f(o)o(v)o(erride)f(binary)g(operators.)23
b(Otherwise,)c(the)g(left)h(operand')-5 b(s)17 b Fo(__op_-)208
3403 y(_\(\))k Ft(method)f(w)o(ould)g(al)o(w)o(ays)i(accept)f(the)g
(right)f(operand:)26 b(when)20 b(an)h(instance)g(of)g(a)h(gi)n(v)o(en)e
(class)i(is)g(e)o(xpected,)e(an)h(instance)208 3503 y(of)e(a)i
(subclass)g(of)e(that)i(class)g(is)g(al)o(w)o(ays)g(acceptable.)125
3666 y Fs(\017)41 b Ft(When)18 b(either)g(operand)e(type)i(de\002nes)h
(a)g(coercion,)e(this)i(coercion)e(is)i(called)f(before)g(that)g(type')
-5 b(s)19 b Fo(__op__\(\))e Ft(or)h Fo(__rop_-)208 3766
y(_\(\))i Ft(method)f(is)j(called,)e(b)n(ut)h(no)f(sooner)-5
b(.)26 b(If)20 b(the)h(coercion)e(returns)h(an)g(object)g(of)h(a)g(dif)
n(ferent)e(type)h(for)g(the)g(operand)f(whose)208 3866
y(coercion)f(is)j(in)m(v)n(ok)o(ed,)d(part)i(of)g(the)g(process)g(is)h
(redone)e(using)h(the)g(ne)n(w)g(object.)125 4029 y Fs(\017)41
b Ft(When)17 b(an)g(in-place)f(operator)g(\(lik)o(e)h(`)p
Fo(+=)p Ft('\))g(is)h(used,)f(if)h(the)f(left)h(operand)d(implements)i
Fo(__iop__\(\))p Ft(,)f(it)i(is)h(in)m(v)n(ok)o(ed)c(without)208
4129 y(an)o(y)27 b(coercion.)48 b(When)28 b(the)g(operation)e(f)o(alls)
j(back)f(to)g Fo(__op__\(\))g Ft(and/or)f Fo(__rop__\(\))p
Ft(,)i(the)f(normal)f(coercion)g(rules)208 4229 y(apply)-5
b(.)125 4393 y Fs(\017)41 b Ft(In)19 b Fq(x)p Fo(+)p
Fq(y)p Ft(,)i(if)f Fq(x)h Ft(is)g(a)g(sequence)e(that)h(implements)f
(sequence)g(concatenation,)f(sequence)h(concatenation)f(is)j(in)m(v)n
(ok)o(ed.)125 4556 y Fs(\017)41 b Ft(In)24 b Fq(x)339
4571 y Fo(*)389 4556 y Fq(y)p Ft(,)h(if)g(one)f(operator)f(is)i(a)g
(sequence)f(that)g(implements)g(sequence)f(repetition,)h(and)g(the)h
(other)e(is)j(an)e(inte)o(ger)g(\()p Fo(int)g Ft(or)208
4656 y Fo(long)p Ft(\),)19 b(sequence)g(repetition)g(is)i(in)m(v)n(ok)o
(ed.)125 4820 y Fs(\017)41 b Ft(Rich)18 b(comparisons)d(\(implemented)h
(by)h(methods)g Fo(__eq__\(\))f Ft(and)h(so)h(on\))f(ne)n(v)o(er)f(use)
i(coercion.)23 b(Three-w)o(ay)16 b(comparison)208 4919
y(\(implemented)h(by)j Fo(__cmp__\(\))p Ft(\))f(does)h(use)g(coercion)f
(under)g(the)h(same)g(conditions)f(as)i(other)e(binary)g(operations)g
(use)h(it.)125 5083 y Fs(\017)41 b Ft(In)20 b(the)h(current)e
(implementation,)f(the)j(b)n(uilt-in)f(numeric)f(types)i
Fo(int)p Ft(,)f Fo(long)h Ft(and)f Fo(float)g Ft(do)h(not)f(use)h
(coercion;)e(the)i(type)208 5183 y Fo(complex)f Ft(ho)n(we)n(v)o(er)g
(does)h(use)h(it.)30 b(The)21 b(dif)n(ference)f(can)i(become)e
(apparent)g(when)h(subclassing)g(these)h(types.)29 b(Ov)o(er)21
b(time,)208 5282 y(the)g(type)f Fo(complex)g Ft(may)h(be)g(\002x)o(ed)f
(to)i(a)n(v)n(oid)e(coercion.)26 b(All)c(these)f(types)g(implement)f(a)
h Fo(__coerce__\(\))f Ft(method,)f(for)208 5382 y(use)h(by)g(the)g(b)n
(uilt-in)g Fo(coerce\(\))f Ft(function.)p 0 5549 3901
4 v 0 5649 a Fp(32)2944 b(Chapter)24 b(3.)52 b(Data)23
b(model)p eop end
%%Page: 33 39
TeXDict begin 33 38 bop 0 83 a Fk(3.4.9)100 b(With)28
b(Statement)h(Conte)m(xt)f(Managers)0 286 y Ft(Ne)n(w)20
b(in)h(v)o(ersion)e(2.5.)0 433 y(A)k Fq(conte)n(xt)g(mana)o(g)o(er)f
Ft(is)i(an)f(object)f(that)h(de\002nes)f(the)h(runtime)f(conte)o(xt)g
(to)h(be)g(established)f(when)g(e)o(x)o(ecuting)f(a)i
Fo(with)g Ft(statement.)0 532 y(The)j(conte)o(xt)e(manager)h(handles)g
(the)h(entry)f(into,)i(and)f(the)g(e)o(xit)f(from,)i(the)f(desired)f
(runtime)g(conte)o(xt)g(for)g(the)h(e)o(x)o(ecution)e(of)i(the)0
632 y(block)c(of)h(code.)32 b(Conte)o(xt)22 b(managers)g(are)g
(normally)g(in)m(v)n(ok)o(ed)f(using)h(the)h Fo(with)g
Ft(statement)g(\(described)e(in)i(section)g(7.5\),)f(b)n(ut)h(can)0
732 y(also)e(be)f(used)g(by)f(directly)h(in)m(v)n(oking)e(their)i
(methods.)0 879 y(T)-7 b(ypical)26 b(uses)h(of)f(conte)o(xt)f(managers)
g(include)g(sa)n(ving)h(and)g(restoring)f(v)n(arious)g(kinds)h(of)g
(global)g(state,)i(locking)d(and)h(unlocking)0 978 y(resources,)19
b(closing)h(opened)e(\002les,)j(etc.)0 1125 y(F)o(or)f(more)f
(information)f(on)i(conte)o(xt)f(managers,)f(see)j(\223Conte)o(xt)e(T)
-7 b(ypes\224)20 b(in)h(the)f Fq(Python)f(Libr)o(ary)h(Refer)m(ence)p
Ft(.)0 1272 y Fh(__enter__)p Fo(\()p Fq(self)12 b Fo(\))208
1372 y Ft(Enter)19 b(the)i(runtime)e(conte)o(xt)h(related)g(to)g(this)i
(object.)j(The)20 b Fo(with)h Ft(statement)f(will)h(bind)f(this)h
(method')-5 b(s)20 b(return)f(v)n(alue)h(to)h(the)208
1471 y(tar)o(get\(s\))d(speci\002ed)i(in)h(the)f Fo(as)g
Ft(clause)g(of)g(the)h(statement,)e(if)i(an)o(y)-5 b(.)0
1618 y Fh(__exit__)p Fo(\()p Fq(self)o(,)19 b(e)n(xc)p
718 1618 25 4 v 30 w(type)o(,)h(e)n(xc)p 1036 1618 V
30 w(value)o(,)f(tr)o(acebac)n(k)q Fo(\))208 1718 y Ft(Exit)h(the)h
(runtime)e(conte)o(xt)g(related)h(to)h(this)g(object.)k(The)c
(parameters)e(describe)h(the)g(e)o(xception)f(that)i(caused)f(the)g
(conte)o(xt)f(to)208 1817 y(be)h(e)o(xited.)k(If)c(the)g(conte)o(xt)f
(w)o(as)i(e)o(xited)e(without)h(an)g(e)o(xception,)e(all)j(three)f(ar)o
(guments)e(will)j(be)f Fo(None)p Ft(.)208 1950 y(If)j(an)h(e)o
(xception)e(is)j(supplied,)f(and)f(the)h(method)e(wishes)j(to)f
(suppress)f(the)h(e)o(xception)e(\(i.e.,)j(pre)n(v)o(ent)d(it)i(from)f
(being)g(prop-)208 2050 y(agated\),)e(it)j(should)d(return)h(a)h(true)f
(v)n(alue.)32 b(Otherwise,)23 b(the)g(e)o(xception)e(will)i(be)g
(processed)e(normally)g(upon)h(e)o(xit)g(from)g(this)208
2149 y(method.)208 2282 y(Note)e(that)g Fo(__exit__)f
Ft(methods)g(should)h(not)f(reraise)h(the)h(passed-in)e(e)o(xception;)f
(this)j(is)g(the)f(caller')-5 b(s)21 b(responsibility)-5
b(.)0 2429 y Fr(See)21 b(Also:)0 2576 y Ft(PEP)g(0343,)d(\223)p
Fq(The)j(\224with\224)g(statement)p Ft(\224)208 2676
y(The)e(speci\002cation,)h(background,)c(and)k(e)o(xamples)f(for)g(the)
i(Python)e Fo(with)h Ft(statement.)p 0 5549 3901 4 v
0 5649 a Fp(3.4.)52 b(Special)24 b(method)g(names)2774
b(33)p eop end
%%Page: 34 40
TeXDict begin 34 39 bop 0 5549 3901 4 v 0 5649 a Fp(34)p
eop end
%%Page: 35 41
TeXDict begin 35 40 bop 0 83 3901 9 v 3503 230 a Fp(CHAPTER)3561
427 y Fn(FOUR)p 0 515 V 2322 978 a Fz(Ex)-6 b(ecution)57
b(model)0 1506 y Fm(4.1)121 b(Naming)34 b(and)g(binding)0
1739 y Fq(Names)20 b Ft(refer)e(to)h(objects.)24 b(Names)19
b(are)g(introduced)e(by)h(name)h(binding)e(operations.)23
b(Each)18 b(occurrence)f(of)i(a)g(name)g(in)g(the)g(program)0
1839 y(te)o(xt)h(refers)g(to)g(the)g Fq(binding)f Ft(of)h(that)g(name)g
(established)f(in)i(the)f(innermost)f(function)f(block)h(containing)g
(the)h(use.)0 1986 y(A)k Fq(bloc)n(k)f Ft(is)h(a)g(piece)f(of)g(Python)
f(program)f(te)o(xt)j(that)f(is)h(e)o(x)o(ecuted)e(as)i(a)f(unit.)35
b(The)23 b(follo)n(wing)e(are)i(blocks:)31 b(a)24 b(module,)f(a)g
(function)0 2085 y(body)-5 b(,)19 b(and)i(a)h(class)g(de\002nition.)27
b(Each)21 b(command)e(typed)h(interacti)n(v)o(ely)g(is)i(a)g(block.)27
b(A)22 b(script)f(\002le)h(\(a)f(\002le)h(gi)n(v)o(en)e(as)i(standard)e
(input)0 2185 y(to)e(the)g(interpreter)f(or)h(speci\002ed)g(on)f(the)i
(interpreter)d(command)g(line)j(the)f(\002rst)h(ar)o(gument\))c(is)k(a)
g(code)e(block.)23 b(A)c(script)f(command)e(\(a)0 2285
y(command)j(speci\002ed)h(on)g(the)g(interpreter)f(command)g(line)h
(with)h(the)f(`)p Fr(-c)p Ft(')g(option\))f(is)j(a)f(code)e(block.)25
b(The)20 b(\002le)i(read)e(by)g(the)g(b)n(uilt-in)0 2384
y(function)d Fo(execfile\(\))g Ft(is)i(a)g(code)f(block.)24
b(The)18 b(string)g(ar)o(gument)e(passed)j(to)f(the)h(b)n(uilt-in)f
(function)f Fo(eval\(\))h Ft(and)g(to)g(the)h Fo(exec)0
2484 y Ft(statement)h(is)h(a)g(code)e(block.)24 b(The)c(e)o(xpression)f
(read)g(and)h(e)n(v)n(aluated)f(by)g(the)i(b)n(uilt-in)e(function)g
Fo(input\(\))g Ft(is)i(a)g(code)e(block.)0 2631 y(A)k(code)f(block)g
(is)h(e)o(x)o(ecuted)e(in)i(an)f Fq(e)n(xecution)g(fr)o(ame)p
Ft(.)32 b(A)23 b(frame)f(contains)g(some)g(administrati)n(v)o(e)f
(information)f(\(used)i(for)g(deb)n(ug-)0 2730 y(ging\))d(and)h
(determines)f(where)g(and)h(ho)n(w)g(e)o(x)o(ecution)e(continues)h
(after)g(the)i(code)e(block')-5 b(s)20 b(e)o(x)o(ecution)e(has)i
(completed.)0 2877 y(A)h Fq(scope)f Ft(de\002nes)g(the)g(visibility)g
(of)g(a)h(name)f(within)g(a)g(block.)25 b(If)20 b(a)h(local)f(v)n
(ariable)f(is)i(de\002ned)e(in)i(a)g(block,)e(its)i(scope)f(includes)f
(that)0 2977 y(block.)28 b(If)21 b(the)h(de\002nition)e(occurs)h(in)h
(a)g(function)d(block,)i(the)h(scope)f(e)o(xtends)f(to)i(an)o(y)f
(blocks)f(contained)g(within)i(the)f(de\002ning)f(one,)0
3077 y(unless)j(a)h(contained)d(block)h(introduces)g(a)h(dif)n(ferent)e
(binding)h(for)g(the)h(name.)33 b(The)23 b(scope)f(of)h(names)g
(de\002ned)f(in)h(a)h(class)g(block)e(is)0 3176 y(limited)e(to)g(the)h
(class)g(block;)e(it)i(does)f(not)g(e)o(xtend)f(to)h(the)g(code)g
(blocks)f(of)h(methods.)0 3323 y(When)d(a)h(name)f(is)h(used)f(in)h(a)f
(code)g(block,)g(it)h(is)g(resolv)o(ed)e(using)h(the)g(nearest)g
(enclosing)f(scope.)24 b(The)17 b(set)h(of)f(all)h(such)f(scopes)h
(visible)0 3423 y(to)i(a)h(code)e(block)h(is)h(called)f(the)g(block')-5
b(s)20 b Fq(en)m(vir)l(onment)p Ft(.)0 3569 y(If)h(a)h(name)f(is)h
(bound)e(in)i(a)f(block,)g(it)h(is)g(a)g(local)g(v)n(ariable)e(of)h
(that)h(block.)27 b(If)22 b(a)g(name)e(is)j(bound)c(at)j(the)g(module)e
(le)n(v)o(el,)h(it)h(is)h(a)e(global)0 3669 y(v)n(ariable.)33
b(\(The)22 b(v)n(ariables)g(of)h(the)g(module)f(code)g(block)g(are)h
(local)g(and)g(global.\))32 b(If)23 b(a)h(v)n(ariable)e(is)i(used)f(in)
g(a)g(code)g(block)f(b)n(ut)h(not)0 3769 y(de\002ned)c(there,)h(it)h
(is)g(a)f Fq(fr)m(ee)h(variable)p Ft(.)0 3916 y(When)f(a)h(name)f(is)i
(not)e(found)e(at)j(all,)g(a)g Fo(NameError)f Ft(e)o(xception)e(is)k
(raised.)j(If)c(the)f(name)g(refers)g(to)h(a)g(local)f(v)n(ariable)g
(that)g(has)h(not)0 4015 y(been)f(bound,)e(a)i Fo(UnboundLocalError)e
Ft(e)o(xception)g(is)j(raised.)k Fo(UnboundLocalError)18
b Ft(is)j(a)f(subclass)h(of)f Fo(NameError)p Ft(.)0 4162
y(The)26 b(follo)n(wing)e(constructs)i(bind)f(names:)37
b(formal)25 b(parameters)g(to)i(functions,)f Fo(import)f
Ft(statements,)j(class)f(and)f(function)e(def-)0 4262
y(initions)i(\(these)g(bind)g(the)g(class)i(or)e(function)f(name)g(in)i
(the)f(de\002ning)g(block\),)g(and)g(tar)o(gets)g(that)g(are)h
(identi\002ers)f(if)g(occurring)e(in)0 4361 y(an)g(assignment,)f
Fo(for)h Ft(loop)f(header)m(,)g(or)g(in)h(the)g(second)f(position)g(of)
g(an)h Fo(except)f Ft(clause)h(header)-5 b(.)35 b(The)23
b Fo(import)g Ft(statement)h(of)0 4461 y(the)c(form)f(\223`)p
Fo(from)49 b(...import)1116 4476 y(*)1166 4461 y Ft(\224')20
b(binds)f(all)i(names)e(de\002ned)g(in)h(the)g(imported)f(module,)f(e)o
(xcept)h(those)h(be)o(ginning)d(with)k(an)0 4561 y(underscore.)i(This)d
(form)f(may)h(only)f(be)h(used)g(at)h(the)f(module)f(le)n(v)o(el.)0
4707 y(A)25 b(tar)o(get)f(occurring)e(in)j(a)g Fo(del)f
Ft(statement)h(is)g(also)g(considered)e(bound)g(for)h(this)h(purpose)e
(\(though)f(the)j(actual)f(semantics)h(are)f(to)0 4807
y(unbind)e(the)i(name\).)36 b(It)25 b(is)g(ille)o(gal)e(to)h(unbind)f
(a)h(name)g(that)g(is)h(referenced)d(by)i(an)g(enclosing)f(scope;)i
(the)g(compiler)d(will)j(report)e(a)0 4907 y Fo(SyntaxError)p
Ft(.)0 5054 y(Each)f(assignment)f(or)h(import)f(statement)h(occurs)f
(within)h(a)h(block)e(de\002ned)g(by)h(a)h(class)g(or)f(function)e
(de\002nition)h(or)h(at)h(the)f(module)0 5153 y(le)n(v)o(el)e(\(the)g
(top-le)n(v)o(el)e(code)i(block\).)0 5300 y(If)g(a)h(name)f(binding)f
(operation)f(occurs)i(an)o(ywhere)e(within)i(a)h(code)f(block,)f(all)i
(uses)g(of)f(the)h(name)f(within)g(the)g(block)g(are)g(treated)g(as)0
5400 y(references)c(to)j(the)e(current)g(block.)23 b(This)18
b(can)g(lead)g(to)g(errors)f(when)g(a)h(name)f(is)i(used)f(within)g(a)g
(block)f(before)f(it)j(is)g(bound.)j(This)c(rule)p 0
5549 3901 4 v 3808 5649 a Fp(35)p eop end
%%Page: 36 42
TeXDict begin 36 41 bop 0 83 a Ft(is)23 b(subtle.)29
b(Python)20 b(lacks)i(declarations)f(and)g(allo)n(ws)h(name)f(binding)f
(operations)g(to)i(occur)e(an)o(ywhere)g(within)h(a)i(code)d(block.)29
b(The)0 183 y(local)19 b(v)n(ariables)e(of)i(a)g(code)e(block)h(can)g
(be)h(determined)e(by)h(scanning)f(the)i(entire)f(te)o(xt)g(of)g(the)h
(block)f(for)g(name)g(binding)e(operations.)0 330 y(If)i(the)h(global)f
(statement)g(occurs)g(within)g(a)h(block,)f(all)h(uses)g(of)f(the)h
(name)f(speci\002ed)g(in)h(the)f(statement)g(refer)g(to)h(the)f
(binding)f(of)h(that)0 429 y(name)i(in)h(the)g(top-le)n(v)o(el)e
(namespace.)26 b(Names)21 b(are)f(resolv)o(ed)g(in)h(the)g(top-le)n(v)o
(el)e(namespace)g(by)i(searching)e(the)i(global)f(namespace,)0
529 y(i.e.)27 b(the)21 b(namespace)f(of)g(the)h(module)f(containing)f
(the)i(code)f(block,)g(and)g(the)h(b)n(uiltin)f(namespace,)g(the)h
(namespace)e(of)i(the)g(module)0 628 y Fo(__builtin__)p
Ft(.)46 b(The)27 b(global)g(namespace)f(is)i(searched)f(\002rst.)48
b(If)27 b(the)h(name)f(is)h(not)g(found)e(there,)i(the)g(b)n(uiltin)f
(namespace)g(is)0 728 y(searched.)d(The)c(global)f(statement)h(must)g
(precede)f(all)i(uses)g(of)f(the)g(name.)0 875 y(The)i(b)n(uilt-in)h
(namespace)e(associated)i(with)g(the)g(e)o(x)o(ecution)d(of)j(a)g(code)
f(block)g(is)i(actually)e(found)f(by)h(looking)f(up)i(the)f(name)h
Fo(__-)0 975 y(builtins__)18 b Ft(in)i(its)h(global)e(namespace;)g
(this)h(should)f(be)g(a)h(dictionary)e(or)i(a)g(module)e(\(in)i(the)g
(latter)g(case)g(the)f(module')-5 b(s)19 b(dictio-)0
1074 y(nary)e(is)j(used\).)j(By)c(def)o(ault,)f(when)g(in)g(the)h
Fo(__main__)e Ft(module,)g Fo(__builtins__)g Ft(is)i(the)g(b)n(uilt-in)
e(module)g Fo(__builtin__-)0 1174 y Ft(\(note:)22 b(no)15
b(`s'\);)i(when)d(in)i(an)o(y)e(other)h(module,)f Fo(__builtins__)g
Ft(is)i(an)f(alias)h(for)f(the)g(dictionary)f(of)h(the)g
Fo(__builtin__)f Ft(module)0 1273 y(itself.)26 b Fo(__builtins__)18
b Ft(can)i(be)g(set)h(to)f(a)h(user)n(-created)e(dictionary)f(to)j
(create)f(a)g(weak)g(form)f(of)h(restricted)g(e)o(x)o(ecution.)0
1420 y Fr(Note:)39 b Ft(Users)28 b(should)e(not)h(touch)f
Fo(__builtins__)p Ft(;)j(it)f(is)h(strictly)e(an)g(implementation)f
(detail.)46 b(Users)28 b(w)o(anting)e(to)i(o)o(v)o(erride)0
1520 y(v)n(alues)18 b(in)h(the)g(b)n(uilt-in)f(namespace)g(should)g
Fo(import)g Ft(the)h Fo(__builtin__)e Ft(\(no)h(`s'\))h(module)e(and)i
(modify)e(its)j(attrib)n(utes)e(appro-)0 1620 y(priately)-5
b(.)0 1766 y(The)17 b(namespace)g(for)g(a)i(module)d(is)j
(automatically)d(created)h(the)h(\002rst)h(time)f(a)g(module)e(is)j
(imported.)k(The)17 b(main)h(module)e(for)h(a)i(script)0
1866 y(is)i(al)o(w)o(ays)g(called)f Fo(__main__)p Ft(.)0
2013 y(The)e(global)f(statement)h(has)g(the)g(same)g(scope)g(as)h(a)f
(name)g(binding)e(operation)g(in)j(the)f(same)g(block.)23
b(If)18 b(the)g(nearest)g(enclosing)f(scope)0 2113 y(for)j(a)g(free)g
(v)n(ariable)f(contains)g(a)i(global)e(statement,)h(the)g(free)g(v)n
(ariable)f(is)i(treated)f(as)h(a)g(global.)0 2259 y(A)30
b(class)g(de\002nition)e(is)j(an)e(e)o(x)o(ecutable)e(statement)i(that)
h(may)f(use)g(and)g(de\002ne)g(names.)52 b(These)29 b(references)f
(follo)n(w)g(the)i(normal)0 2359 y(rules)21 b(for)f(name)h(resolution.)
k(The)c(namespace)f(of)g(the)h(class)h(de\002nition)e(becomes)g(the)h
(attrib)n(ute)g(dictionary)e(of)h(the)h(class.)28 b(Names)0
2459 y(de\002ned)19 b(at)i(the)f(class)h(scope)f(are)g(not)g(visible)g
(in)h(methods.)0 2744 y Fk(4.1.1)100 b(Inter)o(action)29
b(with)f(dynamic)g(f)m(eatures)0 2946 y Ft(There)20 b(are)h(se)n(v)o
(eral)f(cases)h(where)g(Python)e(statements)i(are)g(ille)o(gal)f(when)g
(used)h(in)g(conjunction)d(with)j(nested)g(scopes)g(that)g(contain)0
3046 y(free)f(v)n(ariables.)0 3193 y(If)i(a)h(v)n(ariable)f(is)h
(referenced)e(in)i(an)f(enclosing)f(scope,)i(it)g(is)h(ille)o(gal)e(to)
g(delete)h(the)f(name.)32 b(An)22 b(error)g(will)h(be)g(reported)d(at)k
(compile)0 3293 y(time.)0 3439 y(If)19 b(the)h(wild)g(card)f(form)f(of)
h(import)g(\227)h(`)p Fo(import)1519 3454 y(*)1569 3439
y Ft(')g(\227)g(is)h(used)e(in)h(a)g(function)d(and)i(the)h(function)e
(contains)h(or)g(is)h(a)g(nested)g(block)0 3539 y(with)g(free)g(v)n
(ariables,)f(the)h(compiler)f(will)i(raise)g(a)f Fo(SyntaxError)p
Ft(.)0 3686 y(If)d Fo(exec)g Ft(is)i(used)e(in)g(a)h(function)e(and)g
(the)i(function)d(contains)i(or)g(is)h(a)g(nested)f(block)g(with)g
(free)g(v)n(ariables,)g(the)g(compiler)f(will)i(raise)g(a)0
3786 y Fo(SyntaxError)g Ft(unless)i(the)f(e)o(x)o(ec)g(e)o(xplicitly)f
(speci\002es)i(the)f(local)h(namespace)e(for)h(the)g
Fo(exec)p Ft(.)25 b(\(In)19 b(other)f(w)o(ords,)h(`)p
Fo(exec)49 b(obj)p Ft(')0 3885 y(w)o(ould)19 b(be)i(ille)o(gal,)e(b)n
(ut)h(`)p Fo(exec)49 b(obj)g(in)h(ns)p Ft(')20 b(w)o(ould)f(be)h(le)o
(gal.\))0 4032 y(The)j Fo(eval\(\))p Ft(,)h Fo(execfile\(\))p
Ft(,)f(and)g Fo(input\(\))g Ft(functions)f(and)h(the)g
Fo(exec)h Ft(statement)f(do)g(not)h(ha)n(v)o(e)f(access)h(to)g(the)f
(full)h(en)m(vi-)0 4132 y(ronment)19 b(for)g(resolving)g(names.)25
b(Names)20 b(may)g(be)g(resolv)o(ed)f(in)h(the)h(local)f(and)g(global)f
(namespaces)g(of)h(the)h(caller)-5 b(.)25 b(Free)20 b(v)n(ariables)0
4231 y(are)30 b(not)f(resolv)o(ed)g(in)h(the)g(nearest)f(enclosing)g
(namespace,)i(b)n(ut)f(in)g(the)f(global)g(namespace.)2824
4201 y Fg(1)2910 4231 y Ft(The)h Fo(exec)g Ft(statement)f(and)h(the)0
4331 y Fo(eval\(\))24 b Ft(and)g Fo(execfile\(\))f Ft(functions)g(ha)n
(v)o(e)g(optional)g(ar)o(guments)g(to)h(o)o(v)o(erride)e(the)i(global)g
(and)g(local)g(namespace.)36 b(If)24 b(only)0 4431 y(one)c(namespace)f
(is)i(speci\002ed,)e(it)i(is)g(used)f(for)g(both.)0 4758
y Fm(4.2)121 b(Exceptions)0 4991 y Ft(Exceptions)26 b(are)i(a)g(means)g
(of)f(breaking)f(out)h(of)h(the)g(normal)e(\003o)n(w)i(of)g(control)e
(of)i(a)g(code)f(block)g(in)h(order)e(to)i(handle)f(errors)g(or)0
5090 y(other)e(e)o(xceptional)f(conditions.)41 b(An)27
b(e)o(xception)d(is)j Fq(r)o(aised)f Ft(at)g(the)g(point)g(where)f(the)
h(error)f(is)i(detected;)h(it)f(may)f(be)g Fq(handled)e
Ft(by)0 5190 y(the)i(surrounding)d(code)j(block)f(or)h(by)g(an)o(y)f
(code)h(block)f(that)h(directly)g(or)f(indirectly)g(in)m(v)n(ok)o(ed)g
(the)h(code)g(block)f(where)g(the)i(error)p 0 5261 1560
4 v 90 5317 a Ff(1)120 5340 y Fl(This)16 b(limitation)k(occurs)e
(because)h(the)f(code)g(that)g(is)f(e)o(x)o(ecuted)j(by)d(these)h
(operations)h(is)e(not)g(a)o(v)n(ailable)k(at)c(the)h(time)g(the)f
(module)h(is)f(compiled.)p 0 5549 3901 4 v 0 5649 a Fp(36)2734
b(Chapter)24 b(4.)52 b(Ex)n(ecution)23 b(model)p eop
end
%%Page: 37 43
TeXDict begin 37 42 bop 0 83 a Ft(occurred.)0 230 y(The)30
b(Python)f(interpreter)f(raises)j(an)f(e)o(xception)e(when)h(it)i
(detects)f(a)h(run-time)d(error)h(\(such)h(as)h(di)n(vision)e(by)g
(zero\).)54 b(A)31 b(Python)0 330 y(program)22 b(can)h(also)h(e)o
(xplicitly)f(raise)h(an)f(e)o(xception)f(with)i(the)g
Fo(raise)f Ft(statement.)35 b(Exception)22 b(handlers)h(are)g
(speci\002ed)h(with)g(the)0 429 y Fo(try)30 b Ft(...)54
b Fo(except)29 b Ft(statement.)53 b(The)30 b Fo(try)f
Ft(...)54 b Fo(finally)29 b Ft(statement)h(speci\002es)g(cleanup)f
(code)g(which)g(does)g(not)h(handle)f(the)0 529 y(e)o(xception,)18
b(b)n(ut)i(is)h(e)o(x)o(ecuted)e(whether)g(an)h(e)o(xception)e
(occurred)g(or)i(not)g(in)h(the)f(preceding)e(code.)0
676 y(Python)f(uses)i(the)f(\223termination\224)f(model)g(of)h(error)g
(handling:)k(an)c(e)o(xception)f(handler)g(can)h(\002nd)g(out)g(what)g
(happened)e(and)i(continue)0 775 y(e)o(x)o(ecution)25
b(at)j(an)f(outer)f(le)n(v)o(el,)i(b)n(ut)f(it)h(cannot)e(repair)g(the)
h(cause)h(of)e(the)h(error)f(and)h(retry)f(the)i(f)o(ailing)e
(operation)f(\(e)o(xcept)h(by)h(re-)0 875 y(entering)19
b(the)h(of)n(fending)d(piece)j(of)g(code)g(from)f(the)h(top\).)0
1022 y(When)d(an)g(e)o(xception)e(is)j(not)f(handled)f(at)h(all,)i(the)
e(interpreter)e(terminates)i(e)o(x)o(ecution)e(of)i(the)g(program,)e
(or)i(returns)f(to)i(its)g(interacti)n(v)o(e)0 1121 y(main)i(loop.)k
(In)c(either)g(case,)g(it)h(prints)f(a)g(stack)h(backtrace,)d(e)o
(xcept)i(when)f(the)h(e)o(xception)f(is)i Fo(SystemExit)p
Ft(.)0 1268 y(Exceptions)e(are)h(identi\002ed)f(by)h(class)h
(instances.)k(The)20 b Fo(except)g Ft(clause)g(is)h(selected)g
(depending)c(on)j(the)g(class)i(of)e(the)g(instance:)25
b(it)0 1368 y(must)e(reference)f(the)h(class)i(of)e(the)g(instance)g
(or)g(a)g(base)h(class)g(thereof.)33 b(The)23 b(instance)g(can)g(be)g
(recei)n(v)o(ed)f(by)h(the)g(handler)f(and)h(can)0 1468
y(carry)c(additional)g(information)f(about)h(the)h(e)o(xceptional)f
(condition.)0 1614 y(Exceptions)28 b(can)h(also)h(be)g(identi\002ed)e
(by)h(strings,)j(in)e(which)f(case)h(the)f Fo(except)g
Ft(clause)h(is)g(selected)g(by)f(object)g(identity)-5
b(.)52 b(An)0 1714 y(arbitrary)19 b(v)n(alue)g(can)h(be)g(raised)g
(along)f(with)i(the)f(identifying)e(string)i(which)g(can)g(be)g(passed)
g(to)g(the)g(handler)-5 b(.)0 1861 y Fr(Depr)o(ecated)25
b(since)i(r)o(elease)f(2.5.)43 b Ft(String)26 b(e)o(xceptions)f(should)
h(not)g(be)g(used)g(in)h(ne)n(w)f(code.)43 b(The)o(y)25
b(will)j(not)e(be)g(supported)f(in)h(a)0 1961 y(future)19
b(v)o(ersion)g(of)h(Python.)k(Old)c(code)f(should)h(be)g(re)n(written)f
(to)h(use)h(class)g(e)o(xceptions)e(instead.)p 0 2051
3901 17 v 0 2441 17 391 v 75 2166 a Fr(W)-5 b(ar)o(ning:)56
b Ft(Messages)22 b(to)g(e)o(xceptions)e(are)h(not)h(part)f(of)g(the)h
(Python)f(API.)h(Their)f(contents)g(may)g(change)f(from)h(one)g(v)o
(ersion)75 2266 y(of)d(Python)g(to)i(the)f(ne)o(xt)f(without)g(w)o
(arning)g(and)g(should)g(not)h(be)g(relied)g(on)f(by)h(code)f(which)h
(will)h(run)e(under)f(multiple)i(v)o(ersions)75 2365
y(of)h(the)g(interpreter)-5 b(.)p 3883 2441 V 0 2458
3901 17 v 0 2613 a(See)21 b(also)f(the)g(description)f(of)h(the)g
Fo(try)g Ft(statement)g(in)h(section)f(7.4)f(and)h Fo(raise)g
Ft(statement)g(in)g(section)g(6.9.)p 0 5549 3901 4 v
0 5649 a Fp(4.2.)52 b(Exceptions)3212 b(37)p eop end
%%Page: 38 44
TeXDict begin 38 43 bop 0 5549 3901 4 v 0 5649 a Fp(38)p
eop end
%%Page: 39 45
TeXDict begin 39 44 bop 0 83 3901 9 v 3503 230 a Fp(CHAPTER)3634
427 y Fn(FIVE)p 0 515 V 2775 978 a Fz(Expressions)0 1465
y Ft(This)20 b(chapter)f(e)o(xplains)h(the)g(meaning)f(of)g(the)i
(elements)f(of)f(e)o(xpressions)g(in)i(Python.)0 1612
y Fr(Syntax)g(Notes:)27 b Ft(In)21 b(this)h(and)f(the)h(follo)n(wing)d
(chapters,)i(e)o(xtended)f(BNF)i(notation)f(will)h(be)f(used)g(to)h
(describe)f(syntax,)g(not)g(le)o(xical)0 1712 y(analysis.)k(When)20
b(\(one)f(alternati)n(v)o(e)g(of\))h(a)g(syntax)g(rule)g(has)g(the)g
(form)216 1857 y Fo(name)99 b Ft(::=)g Fo(othername)0
2005 y Ft(and)20 b(no)f(semantics)i(are)f(gi)n(v)o(en,)e(the)j
(semantics)f(of)g(this)g(form)g(of)f Fo(name)h Ft(are)h(the)f(same)g
(as)h(for)f Fo(othername)p Ft(.)0 2333 y Fm(5.1)121 b(Ar)r(ithmetic)32
b(con)n(v)m(ersions)0 2565 y Ft(When)16 b(a)h(description)d(of)i(an)h
(arithmetic)e(operator)f(belo)n(w)i(uses)h(the)f(phrase)g(\223the)g
(numeric)e(ar)o(guments)h(are)h(con)m(v)o(erted)d(to)k(a)f(common)0
2665 y(type,)-6 b(\224)17 b(the)h(ar)o(guments)d(are)i(coerced)f(using)
h(the)g(coercion)f(rules)h(listed)h(at)35 b(3.4.8.)23
b(If)17 b(both)g(ar)o(guments)e(are)i(standard)f(numeric)g(types,)0
2765 y(the)k(follo)n(wing)f(coercions)g(are)h(applied:)125
2995 y Fs(\017)41 b Ft(If)20 b(either)f(ar)o(gument)f(is)j(a)g(comple)o
(x)d(number)m(,)g(the)i(other)g(is)h(con)m(v)o(erted)c(to)k(comple)o
(x;)125 3161 y Fs(\017)41 b Ft(otherwise,)19 b(if)h(either)g(ar)o
(gument)e(is)j(a)g(\003oating)e(point)h(number)m(,)d(the)k(other)e(is)i
(con)m(v)o(erted)d(to)i(\003oating)f(point;)125 3327
y Fs(\017)41 b Ft(otherwise,)19 b(if)h(either)g(ar)o(gument)e(is)j(a)g
(long)e(inte)o(ger)m(,)g(the)h(other)f(is)i(con)m(v)o(erted)d(to)i
(long)g(inte)o(ger;)125 3493 y Fs(\017)41 b Ft(otherwise,)19
b(both)g(must)h(be)h(plain)e(inte)o(gers)h(and)f(no)h(con)m(v)o(ersion)
e(is)j(necessary)-5 b(.)0 3723 y(Some)27 b(additional)e(rules)i(apply)f
(for)h(certain)f(operators)g(\(e.g.,)h(a)h(string)e(left)i(ar)o(gument)
c(to)k(the)f(`\045')g(operator\).)43 b(Extensions)26
b(can)0 3822 y(de\002ne)20 b(their)g(o)n(wn)f(coercions.)0
4150 y Fm(5.2)121 b(Atoms)0 4383 y Ft(Atoms)24 b(are)h(the)f(most)h
(basic)g(elements)f(of)g(e)o(xpressions.)36 b(The)25
b(simplest)f(atoms)h(are)f(identi\002ers)g(or)h(literals.)38
b(F)o(orms)24 b(enclosed)f(in)0 4482 y(re)n(v)o(erse)d(quotes)h(or)g
(in)h(parentheses,)e(brack)o(ets)h(or)h(braces)f(are)g(also)h(cate)o
(gorized)d(syntactically)i(as)h(atoms.)29 b(The)21 b(syntax)g(for)g
(atoms)0 4582 y(is:)216 4708 y Fo(atom)348 b Ft(::=)99
b Fo(identifier)48 b(|)i(literal)e(|)i(enclosure)216
4808 y(enclosure)98 b Ft(::=)h Fo(parenth_form)48 b(|)i(list_display)
956 4907 y(|)g(generator_expression)c(|)k(dict_display)956
5007 y(|)g(string_conversion)d(|)i(yield_atom)p 0 5549
3901 4 v 3808 5649 a Fp(39)p eop end
%%Page: 40 46
TeXDict begin 40 45 bop 0 83 a Fk(5.2.1)100 b(Identi\002ers)29
b(\(Names\))0 286 y Ft(An)22 b(identi\002er)f(occurring)e(as)k(an)e
(atom)h(is)g(a)g(name.)29 b(See)22 b(section)g(2.3)f(for)g(le)o(xical)g
(de\002nition)g(and)g(section)g(4.1)g(for)h(documentation)0
386 y(of)e(naming)f(and)g(binding.)0 532 y(When)g(the)g(name)f(is)i
(bound)d(to)i(an)f(object,)h(e)n(v)n(aluation)e(of)i(the)f(atom)h
(yields)g(that)g(object.)24 b(When)18 b(a)i(name)e(is)i(not)e(bound,)f
(an)i(attempt)0 632 y(to)h(e)n(v)n(aluate)g(it)g(raises)h(a)g
Fo(NameError)e Ft(e)o(xception.)0 779 y Fr(Pri)o(v)o(ate)31
b(name)i(mangling:)49 b Ft(When)32 b(an)g(identi\002er)g(that)g(te)o
(xtually)f(occurs)h(in)g(a)h(class)g(de\002nition)e(be)o(gins)g(with)i
(tw)o(o)f(or)g(more)0 879 y(underscore)27 b(characters)h(and)h(does)g
(not)f(end)h(in)g(tw)o(o)h(or)f(more)f(underscores,)h(it)h(is)g
(considered)e(a)h Fq(private)g(name)g Ft(of)g(that)g(class.)0
978 y(Pri)n(v)n(ate)18 b(names)h(are)f(transformed)e(to)j(a)g(longer)f
(form)f(before)g(code)h(is)i(generated)d(for)h(them.)24
b(The)18 b(transformation)e(inserts)j(the)g(class)0 1078
y(name)24 b(in)h(front)f(of)h(the)g(name,)g(with)g(leading)f
(underscores)f(remo)o(v)o(ed,)g(and)h(a)i(single)e(underscore)f
(inserted)h(in)h(front)f(of)h(the)g(class)0 1177 y(name.)41
b(F)o(or)26 b(e)o(xample,)f(the)h(identi\002er)g Fo(__spam)f
Ft(occurring)e(in)j(a)h(class)g(named)d Fo(Ham)i Ft(will)h(be)f
(transformed)d(to)j Fo(_Ham__spam)p Ft(.)0 1277 y(This)d
(transformation)c(is)24 b(independent)19 b(of)j(the)h(syntactical)f
(conte)o(xt)f(in)h(which)g(the)g(identi\002er)g(is)h(used.)32
b(If)22 b(the)g(transformed)e(name)0 1377 y(is)30 b(e)o(xtremely)e
(long)g(\(longer)f(than)i(255)f(characters\),)i(implementation)d
(de\002ned)h(truncation)f(may)i(happen.)50 b(If)29 b(the)g(class)h
(name)0 1476 y(consists)21 b(only)e(of)h(underscores,)e(no)i
(transformation)d(is)k(done.)0 1761 y Fk(5.2.2)100 b(Liter)o(als)0
1964 y Ft(Python)19 b(supports)g(string)h(literals)h(and)e(v)n(arious)g
(numeric)g(literals:)216 2107 y Fo(literal)98 b Ft(::=)i
Fo(stringliteral)47 b(|)j(integer)e(|)i(longinteger)857
2207 y(|)f(floatnumber)f(|)i(imagnumber)0 2349 y Ft(Ev)n(aluation)20
b(of)i(a)h(literal)f(yields)g(an)g(object)g(of)f(the)h(gi)n(v)o(en)f
(type)h(\(string,)f(inte)o(ger)m(,)g(long)h(inte)o(ger)m(,)e
(\003oating)i(point)f(number)m(,)f(comple)o(x)0 2449
y(number\))f(with)j(the)g(gi)n(v)o(en)e(v)n(alue.)28
b(The)22 b(v)n(alue)f(may)g(be)g(approximated)e(in)j(the)f(case)h(of)g
(\003oating)e(point)h(and)g(imaginary)f(\(comple)o(x\))0
2548 y(literals.)25 b(See)c(section)f(2.4)g(for)f(details.)0
2695 y(All)e(literals)g(correspond)c(to)j(immutable)f(data)h(types,)h
(and)e(hence)h(the)g(object')-5 b(s)16 b(identity)f(is)i(less)h
(important)c(than)i(its)h(v)n(alue.)23 b(Multiple)0 2795
y(e)n(v)n(aluations)f(of)h(literals)h(with)f(the)g(same)h(v)n(alue)e
(\(either)h(the)g(same)g(occurrence)e(in)j(the)f(program)e(te)o(xt)i
(or)g(a)h(dif)n(ferent)d(occurrence\))0 2894 y(may)f(obtain)f(the)h
(same)h(object)e(or)h(a)h(dif)n(ferent)d(object)i(with)g(the)h(same)f
(v)n(alue.)0 3179 y Fk(5.2.3)100 b(P)l(arenthesiz)o(ed)30
b(f)m(or)r(ms)0 3382 y Ft(A)21 b(parenthesized)d(form)h(is)i(an)f
(optional)f(e)o(xpression)g(list)i(enclosed)e(in)i(parentheses:)216
3528 y Fo(parenth_form)97 b Ft(::=)j Fo("\(")49 b([expression_list])e
("\)")0 3676 y Ft(A)25 b(parenthesized)d(e)o(xpression)g(list)j(yields)
f(whate)n(v)o(er)f(that)h(e)o(xpression)f(list)i(yields:)33
b(if)24 b(the)g(list)i(contains)d(at)i(least)f(one)g(comma,)g(it)0
3776 y(yields)c(a)h(tuple;)f(otherwise,)f(it)i(yields)f(the)g(single)g
(e)o(xpression)f(that)h(mak)o(es)g(up)g(the)g(e)o(xpression)f(list.)0
3922 y(An)26 b(empty)g(pair)g(of)g(parentheses)f(yields)h(an)g(empty)f
(tuple)h(object.)43 b(Since)26 b(tuples)g(are)g(immutable,)h(the)f
(rules)g(for)g(literals)h(apply)0 4022 y(\(i.e.,)20 b(tw)o(o)g
(occurrences)e(of)i(the)g(empty)g(tuple)f(may)h(or)g(may)g(not)g(yield)
f(the)i(same)f(object\).)0 4169 y(Note)27 b(that)g(tuples)g(are)f(not)h
(formed)e(by)i(the)g(parentheses,)g(b)n(ut)g(rather)f(by)g(use)h(of)g
(the)g(comma)f(operator)-5 b(.)43 b(The)27 b(e)o(xception)e(is)j(the)0
4269 y(empty)c(tuple,)h(for)f(which)g(parentheses)g Fq(ar)m(e)g
Ft(required)f(\227)i(allo)n(wing)f(unparenthesized)e(\223nothing\224)h
(in)h(e)o(xpressions)g(w)o(ould)g(cause)0 4368 y(ambiguities)19
b(and)h(allo)n(w)g(common)e(typos)i(to)g(pass)h(uncaught.)0
4653 y Fk(5.2.4)100 b(List)28 b(displa)m(ys)0 4856 y
Ft(A)21 b(list)g(display)f(is)h(a)f(possibly)g(empty)f(series)i(of)f(e)
o(xpressions)f(enclosed)g(in)h(square)g(brack)o(ets:)p
0 5549 3901 4 v 0 5649 a Fp(40)2917 b(Chapter)23 b(5.)52
b(Expressions)p eop end
%%Page: 41 47
TeXDict begin 41 46 bop 216 70 a Fo(list_display)446
b Ft(::=)100 b Fo("[")49 b([expression_list)e(|)i(list_comprehension])e
("]")216 169 y(list_comprehension)146 b Ft(::=)100 b
Fo(expression)47 b(list_for)216 269 y(list_for)646 b
Ft(::=)100 b Fo("for")48 b(target_list)g("in")h(old_expression_list)e
([list_iter])216 369 y(old_expression_list)96 b Ft(::=)k
Fo(old_expression)47 b([\(",")i(old_expression\)+)d([","]])216
468 y(list_iter)596 b Ft(::=)100 b Fo(list_for)48 b(|)h(list_if)216
568 y(list_if)696 b Ft(::=)100 b Fo("if")49 b(old_expression)e
([list_iter])0 753 y Ft(A)30 b(list)g(display)f(yields)g(a)h(ne)n(w)f
(list)i(object.)51 b(Its)30 b(contents)f(are)g(speci\002ed)g(by)g(pro)o
(viding)e(either)h(a)i(list)h(of)e(e)o(xpressions)f(or)h(a)g(list)0
853 y(comprehension.)47 b(When)20 b(a)g(comma-separated)c(list)21
b(of)f(e)o(xpressions)e(is)j(supplied,)d(its)j(elements)e(are)h(e)n(v)n
(aluated)e(from)g(left)i(to)g(right)0 952 y(and)i(placed)g(into)h(the)g
(list)h(object)e(in)h(that)g(order)-5 b(.)32 b(When)23
b(a)g(list)h(comprehension)c(is)j(supplied,)g(it)g(consists)h(of)e(a)h
(single)g(e)o(xpression)0 1052 y(follo)n(wed)g(by)i(at)g(least)g(one)f
Fo(for)h Ft(clause)g(and)f(zero)g(or)g(more)g Fo(for)h
Ft(or)f Fo(if)h Ft(clauses.)39 b(In)25 b(this)g(case,)h(the)e(elements)
h(of)f(the)h(ne)n(w)f(list)0 1151 y(are)19 b(those)g(that)h(w)o(ould)e
(be)i(produced)c(by)j(considering)f(each)h(of)g(the)g
Fo(for)g Ft(or)g Fo(if)h Ft(clauses)f(a)h(block,)e(nesting)h(from)f
(left)i(to)f(right,)g(and)0 1251 y(e)n(v)n(aluating)f(the)j(e)o
(xpression)d(to)j(produce)d(a)i(list)i(element)d(each)h(time)h(the)f
(innermost)f(block)g(is)i(reached)3054 1221 y Fg(1)3085
1251 y Ft(.)0 1536 y Fk(5.2.5)100 b(Gener)o(ator)29 b(e)m(xpressions)0
1739 y Ft(A)21 b(generator)d(e)o(xpression)h(is)i(a)f(compact)f
(generator)g(notation)f(in)j(parentheses:)216 1882 y
Fo(generator_expression)96 b Ft(::=)j Fo("\(")50 b(expression)e
(genexpr_for)f("\)")216 1982 y(genexpr_for)546 b Ft(::=)99
b Fo("for")49 b(target_list)f("in")h(or_test)g([genexpr_iter])216
2081 y(genexpr_iter)496 b Ft(::=)99 b Fo(genexpr_for)48
b(|)i(genexpr_if)216 2181 y(genexpr_if)596 b Ft(::=)99
b Fo("if")49 b(old_expression)f([genexpr_iter])0 2323
y Ft(A)21 b(generator)e(e)o(xpression)g(yields)h(a)h(ne)n(w)g
(generator)d(object.)53 b(It)21 b(consists)g(of)f(a)h(single)g(e)o
(xpression)e(follo)n(wed)g(by)h(at)h(least)h(one)e Fo(for)0
2423 y Ft(clause)d(and)g(zero)g(or)f(more)h Fo(for)g
Ft(or)g Fo(if)g Ft(clauses.)25 b(The)16 b(iterating)h(v)n(alues)g(of)g
(the)g(ne)n(w)g(generator)e(are)i(those)g(that)g(w)o(ould)g(be)g
(produced)0 2522 y(by)h(considering)f(each)h(of)h(the)f
Fo(for)h Ft(or)g Fo(if)f Ft(clauses)i(a)f(block,)e(nesting)i(from)e
(left)i(to)g(right,)f(and)g(e)n(v)n(aluating)f(the)i(e)o(xpression)e
(to)i(yield)0 2622 y(a)i(v)n(alue)e(that)h(is)i(reached)c(the)j
(innermost)d(block)i(for)f(each)h(iteration.)0 2769 y(V)-9
b(ariables)17 b(used)h(in)f(the)h(generator)e(e)o(xpression)g(are)h(e)n
(v)n(aluated)g(lazily)g(when)g(the)h Fo(next\(\))f Ft(method)f(is)j
(called)e(for)g(generator)f(object)0 2868 y(\(in)22 b(the)h(same)g(f)o
(ashion)e(as)i(normal)f(generators\).)30 b(Ho)n(we)n(v)o(er)m(,)21
b(the)h(leftmost)g Fo(for)h Ft(clause)f(is)i(immediately)d(e)n(v)n
(aluated)g(so)i(that)g(error)0 2968 y(produced)13 b(by)i(it)h(can)f(be)
h(seen)f(before)f(an)o(y)h(other)g(possible)g(error)f(in)i(the)f(code)g
(that)h(handles)e(the)i(generator)d(e)o(xpression.)22
b(Subsequent)0 3068 y Fo(for)e Ft(clauses)g(cannot)f(be)g(e)n(v)n
(aluated)g(immediately)f(since)i(the)o(y)f(may)h(depend)e(on)h(the)h
(pre)n(vious)e Fo(for)i Ft(loop.)k(F)o(or)19 b(e)o(xample:)24
b(`)p Fo(\(x)3801 3083 y(*)3851 3068 y(y)0 3167 y(for)49
b(x)h(in)f(range\(10\))f(for)i(y)f(in)h(bar\(x\)\))p
Ft('.)0 3314 y(The)20 b(parentheses)f(can)h(be)g(omitted)f(on)h(calls)h
(with)g(only)e(one)h(ar)o(gument.)i(See)f(section)f(5.3.4)f(for)g(the)h
(detail.)0 3599 y Fk(5.2.6)100 b(Dictionar)s(y)29 b(displa)m(ys)0
3802 y Ft(A)21 b(dictionary)d(display)i(is)h(a)f(possibly)g(empty)f
(series)i(of)f(k)o(e)o(y/datum)e(pairs)i(enclosed)g(in)g(curly)f
(braces:)216 3945 y Fo(dict_display)197 b Ft(::=)99 b
Fo("{")50 b([key_datum_list])d("}")216 4045 y(key_datum_list)97
b Ft(::=)i Fo(key_datum)49 b(\(",")g(key_datum\))2453
4060 y(*)2550 4045 y([","])216 4144 y(key_datum)347 b
Ft(::=)99 b Fo(expression)48 b(":")i(expression)0 4287
y Ft(A)21 b(dictionary)d(display)i(yields)g(a)g(ne)n(w)g(dictionary)f
(object.)0 4433 y(The)g(k)o(e)o(y/datum)f(pairs)h(are)g(e)n(v)n
(aluated)f(from)h(left)g(to)h(right)f(to)g(de\002ne)g(the)h(entries)f
(of)g(the)h(dictionary:)j(each)c(k)o(e)o(y)g(object)f(is)j(used)e(as)h
(a)0 4533 y(k)o(e)o(y)g(into)g(the)g(dictionary)e(to)i(store)h(the)f
(corresponding)d(datum.)0 4680 y(Restrictions)32 b(on)f(the)h(types)g
(of)f(the)h(k)o(e)o(y)f(v)n(alues)h(are)f(listed)i(earlier)e(in)h
(section)f(3.2.)59 b(\(T)-7 b(o)32 b(summarize,)h(the)f(k)o(e)o(y)f
(type)h(should)0 4780 y(be)27 b(hashable,)g(which)g(e)o(xcludes)e(all)j
(mutable)e(objects.\))44 b(Clashes)28 b(between)e(duplicate)g(k)o(e)o
(ys)h(are)g(not)f(detected;)k(the)d(last)g(datum)0 4879
y(\(te)o(xtually)19 b(rightmost)g(in)h(the)g(display\))g(stored)f(for)h
(a)g(gi)n(v)o(en)f(k)o(e)o(y)h(v)n(alue)f(pre)n(v)n(ails.)p
0 4950 1560 4 v 90 5006 a Ff(1)120 5029 y Fl(In)d(Python)i(2.3,)e(a)g
(list)i(comprehension)h(\224leaks\224)f(the)g(control)g(v)n(ariables)i
(of)c(each)i(`)p Fb(for)p Fl(')e(it)h(contains)i(into)e(the)h
(containing)i(scope.)h(Ho)n(we)n(v)o(er)m(,)d(this)f(beha)o(vior)i(is)0
5108 y(deprecated,)h(and)d(relying)i(on)e(it)h(will)g(not)f(w)o(ork)h
(once)g(this)f(b)o(ug)g(is)g(\002x)o(ed)g(in)h(a)f(future)h(release)p
0 5549 3901 4 v 0 5649 a Fp(5.2.)52 b(Atoms)3383 b(41)p
eop end
%%Page: 42 48
TeXDict begin 42 47 bop 0 83 a Fk(5.2.7)100 b(Str)q(ing)30
b(con)n(v)n(ersions)0 286 y Ft(A)21 b(string)f(con)m(v)o(ersion)d(is)k
(an)f(e)o(xpression)f(list)i(enclosed)e(in)i(re)n(v)o(erse)e(\(a.k.a.)
24 b(backw)o(ard\))18 b(quotes:)216 432 y Fo(string_conversion)96
b Ft(::=)k Fo("`")49 b(expression_list)e("`")0 580 y
Ft(A)22 b(string)e(con)m(v)o(ersion)f(e)n(v)n(aluates)h(the)h
(contained)f(e)o(xpression)f(list)j(and)f(con)m(v)o(erts)e(the)i
(resulting)g(object)f(into)h(a)h(string)e(according)f(to)0
679 y(rules)h(speci\002c)h(to)f(its)h(type.)0 826 y(If)k(the)h(object)f
(is)h(a)g(string,)g(a)g(number)m(,)e Fo(None)p Ft(,)j(or)e(a)h(tuple,)g
(list)g(or)f(dictionary)f(containing)g(only)g(objects)h(whose)h(type)f
(is)h(one)f(of)0 926 y(these,)f(the)f(resulting)f(string)h(is)h(a)f(v)n
(alid)g(Python)f(e)o(xpression)f(which)i(can)f(be)h(passed)g(to)g(the)h
(b)n(uilt-in)e(function)f Fo(eval\(\))i Ft(to)g(yield)0
1025 y(an)d(e)o(xpression)f(with)h(the)g(same)h(v)n(alue)e(\(or)h(an)g
(approximation,)d(if)j(\003oating)g(point)f(numbers)g(are)h(in)m(v)n
(olv)o(ed\).)0 1172 y(\(In)i(particular)m(,)g(con)m(v)o(erting)e(a)j
(string)f(adds)h(quotes)f(around)f(it)i(and)g(con)m(v)o(erts)e
(\223funn)o(y\224)f(characters)i(to)h(escape)g(sequences)f(that)h(are)0
1272 y(safe)d(to)h(print.\))0 1419 y(Recursi)n(v)o(e)31
b(objects)g(\(for)f(e)o(xample,)j(lists)f(or)f(dictionaries)g(that)g
(contain)f(a)i(reference)e(to)h(themselv)o(es,)j(directly)c(or)h
(indirectly\))0 1518 y(use)j(`)p Fo(...)p Ft(')67 b(to)34
b(indicate)g(a)h(recursi)n(v)o(e)d(reference,)k(and)e(the)g(result)g
(cannot)g(be)g(passed)g(to)g Fo(eval\(\))g Ft(to)g(get)g(an)h(equal)e
(v)n(alue)0 1618 y(\()p Fo(SyntaxError)18 b Ft(will)j(be)f(raised)g
(instead\).)0 1765 y(The)e(b)n(uilt-in)g(function)e Fo(repr\(\))i
Ft(performs)f(e)o(xactly)g(the)i(same)f(con)m(v)o(ersion)e(in)j(its)g
(ar)o(gument)d(as)j(enclosing)e(it)i(in)g(parentheses)e(and)0
1865 y(re)n(v)o(erse)i(quotes)h(does.)k(The)c(b)n(uilt-in)g(function)e
Fo(str\(\))i Ft(performs)f(a)h(similar)h(b)n(ut)f(more)f(user)n
(-friendly)f(con)m(v)o(ersion.)0 2149 y Fk(5.2.8)100
b(Y)n(ield)29 b(e)m(xpressions)50 2352 y Fo(yield_atom)396
b Ft(::=)100 b Fo("\(")49 b(yield_expression)e("\)")50
2451 y(yield_expression)96 b Ft(::=)k Fo("yield")49 b
([expression_list])0 2593 y Ft(Ne)n(w)20 b(in)h(v)o(ersion)e(2.5.)0
2740 y(The)e Fo(yield)h Ft(e)o(xpression)e(is)j(only)e(used)g(when)g
(de\002ning)g(a)h(generator)e(function,)g(and)h(can)h(only)e(be)i(used)
g(in)g(the)f(body)g(of)g(a)h(function)0 2840 y(de\002nition.)23
b(Using)c(a)h Fo(yield)f Ft(e)o(xpression)e(in)i(a)h(function)d
(de\002nition)h(is)i(suf)n(\002cient)f(to)g(cause)g(that)g
(de\002nition)f(to)h(create)g(a)h(generator)0 2939 y(function)e
(instead)i(of)g(a)h(normal)e(function.)0 3086 y(When)29
b(a)h(generator)e(function)g(is)i(called,)i(it)e(returns)f(an)g
(iterator)g(kno)n(wn)f(as)i(a)g(generator)-5 b(.)52 b(That)29
b(generator)f(then)h(controls)g(the)0 3186 y(e)o(x)o(ecution)16
b(of)i(a)g(generator)e(function.)22 b(The)c(e)o(x)o(ecution)e(starts)j
(when)e(one)h(of)f(the)h(generator')-5 b(s)17 b(methods)g(is)i(called.)
24 b(At)18 b(that)g(time,)h(the)0 3285 y(e)o(x)o(ecution)14
b(proceeds)g(to)i(the)g(\002rst)h Fo(yield)e Ft(e)o(xpression,)g(where)
h(it)g(is)h(suspended)d(again,)i(returning)e(the)h(v)n(alue)h(of)f
Fo(expression_-)0 3385 y(list)25 b Ft(to)g(generator')-5
b(s)24 b(caller)-5 b(.)40 b(By)25 b(suspended)f(we)h(mean)f(that)i(all)
f(local)g(state)h(is)g(retained,)f(including)e(the)i(current)f
(bindings)g(of)0 3485 y(local)i(v)n(ariables,)f(the)h(instruction)e
(pointer)m(,)i(and)f(the)g(internal)g(e)n(v)n(aluation)f(stack.)41
b(When)26 b(the)f(e)o(x)o(ecution)f(is)i(resumed)f(by)g(calling)0
3584 y(one)19 b(of)g(the)g(generator')-5 b(s)17 b(methods,)i(the)g
(function)e(can)i(proceed)f(e)o(xactly)g(as)i(if)g(the)f
Fo(yield)g Ft(e)o(xpression)e(w)o(as)j(just)g(another)e(e)o(xternal)0
3684 y(call.)25 b(The)20 b(v)n(alue)g(of)g(the)g Fo(yield)g
Ft(e)o(xpression)e(after)i(resuming)f(depends)g(on)g(the)i(method)d
(which)i(resumed)f(the)h(e)o(x)o(ecution.)0 3831 y(All)k(of)e(this)i
(mak)o(es)f(generator)e(functions)g(quite)i(similar)g(to)g(coroutines;)
g(the)o(y)g(yield)f(multiple)h(times,)h(the)o(y)e(ha)n(v)o(e)g(more)h
(than)f(one)0 3930 y(entry)16 b(point)h(and)g(their)g(e)o(x)o(ecution)e
(can)i(be)g(suspended.)23 b(The)17 b(only)f(dif)n(ference)g(is)i(that)f
(a)h(generator)d(function)h(cannot)g(control)g(where)0
4030 y(should)j(the)h(e)o(x)o(ecution)e(continue)h(after)h(it)h
(yields;)f(the)g(control)f(is)i(al)o(w)o(ays)g(transfered)e(to)h(the)g
(generator')-5 b(s)19 b(caller)-5 b(.)0 4177 y(The)20
b(follo)n(wing)e(generator')-5 b(s)19 b(methods)g(can)h(be)g(used)g(to)
h(control)d(the)j(e)o(x)o(ecution)d(of)i(a)g(generator)f(function:)0
4324 y Fh(next)p Fo(\(\))208 4423 y Ft(Starts)32 b(the)f(e)o(x)o
(ecution)e(of)i(a)h(generator)d(function)h(or)h(resumes)g(it)h(at)g
(the)f(last)i(e)o(x)o(ecuted)c Fo(yield)i Ft(e)o(xpression.)57
b(When)31 b(a)208 4523 y(generator)14 b(function)h(is)i(resumed)e(with)
i(a)f Fo(next\(\))g Ft(method,)g(the)g(current)f Fo(yield)h
Ft(e)o(xpression)f(al)o(w)o(ays)i(e)n(v)n(aluates)e(to)i
Fo(None)p Ft(.)208 4623 y(The)24 b(e)o(x)o(ecution)f(then)h(continues)g
(to)h(the)g(ne)o(xt)f Fo(yield)h Ft(e)o(xpression,)f(where)g(the)h
(generator)e(is)j(suspended)d(again,)i(and)g(the)208
4722 y(v)n(alue)31 b(of)i(the)f Fo(expression_list)f
Ft(is)i(returned)e(to)i Fo(next\(\))p Ft(')-5 b(s)32
b(caller)-5 b(.)63 b(If)32 b(the)h(generator)d(e)o(xits)j(without)f
(yielding)208 4822 y(another)18 b(v)n(alue,)i(a)g Fo(StopIteration)e
Ft(e)o(xception)h(is)i(raised.)0 4969 y Fh(send)p Fo(\()p
Fq(value)p Fo(\))208 5068 y Ft(Resumes)28 b(the)h(e)o(x)o(ecution)d
(and)i(\223sends\224)g(a)g(v)n(alue)g(into)g(the)g(generator)f
(function.)47 b(The)28 b Fo(value)g Ft(ar)o(gument)e(becomes)i(the)208
5168 y(result)18 b(of)f(the)h(current)f Fo(yield)g Ft(e)o(xpression.)23
b(The)17 b Fo(send\(\))h Ft(method)e(returns)h(the)h(ne)o(xt)f(v)n
(alue)h(yielded)f(by)g(the)h(generator)m(,)e(or)208 5268
y(raises)j Fo(StopIteration)f Ft(if)h(the)h(generator)d(e)o(xits)i
(without)g(yielding)f(another)g(v)n(alue.)24 b(When)19
b Fo(send\(\))f Ft(is)j(called)e(to)g(start)208 5367
y(the)24 b(generator)m(,)e(it)j(must)f(be)g(called)g(with)h
Fo(None)f Ft(as)g(the)h(ar)o(gument,)d(because)i(there)f(is)i(no)f
Fo(yield)g Ft(e)o(xpression)e(that)j(could)p 0 5549 3901
4 v 0 5649 a Fp(42)2917 b(Chapter)23 b(5.)52 b(Expressions)p
eop end
%%Page: 43 49
TeXDict begin 43 48 bop 208 83 a Ft(receie)n(v)o(e)19
b(the)h(v)n(alue.)0 230 y Fh(throw)p Fo(\()p Fq(type)p
Fc([)p Fq(,)f(value)p Fc([)p Fq(,)g(tr)o(acebac)n(k)13
b Fc(])f(])p Fo(\))208 330 y Ft(Raises)24 b(an)e(e)o(xception)f(of)i
(type)f Fo(type)h Ft(at)g(the)g(point)f(where)g(generator)f(w)o(as)i
(paused,)g(and)f(returns)g(the)g(ne)o(xt)h(v)n(alue)f(yielded)208
429 y(by)d(the)h(generator)e(function.)23 b(If)d(the)g(generator)e(e)o
(xits)i(without)f(yielding)g(another)f(v)n(alue,)h(a)h
Fo(StopIteration)e Ft(e)o(xception)208 529 y(is)24 b(raised.)33
b(If)23 b(the)h(generator)d(function)g(does)i(not)g(catch)g(the)g
(passed-in)g(e)o(xception,)e(or)i(raises)h(a)g(dif)n(ferent)d(e)o
(xception,)h(then)208 628 y(that)e(e)o(xception)e(propagates)g(to)i
(the)h(caller)-5 b(.)0 775 y Fh(close)p Fo(\(\))208 875
y Ft(Raises)18 b(a)g Fo(GeneratorExit)e Ft(at)i(the)f(point)g(where)g
(the)g(generator)f(function)g(w)o(as)i(paused.)23 b(If)17
b(the)h(generator)d(function)h(then)208 975 y(raises)24
b Fo(StopIteration)e Ft(\(by)i(e)o(xiting)e(normally)-5
b(,)23 b(or)h(due)f(to)i(already)d(being)h(closed\))h(or)g
Fo(GeneratorExit)e Ft(\(by)h(not)208 1074 y(catching)d(the)h(e)o
(xception\),)f(close)h(returns)g(to)g(its)i(caller)-5
b(.)29 b(If)21 b(the)h(generator)d(yields)i(a)h(v)n(alue,)f(a)h
Fo(RuntimeError)e Ft(is)i(raised.)208 1174 y(If)h(the)g(generator)f
(raises)i(an)o(y)e(other)h(e)o(xception,)f(it)i(is)h(propagated)20
b(to)k(the)f(caller)-5 b(.)35 b Fo(close)23 b Ft(does)h(nothing)d(if)j
(the)g(generator)208 1273 y(has)c(already)f(e)o(xited)g(due)h(to)g(an)h
(e)o(xception)d(or)i(normal)f(e)o(xit.)0 1420 y(Here)h(is)h(a)g(simple)
f(e)o(xample)f(that)h(demonstrates)f(the)h(beha)n(vior)f(of)h
(generators)e(and)i(generator)e(functions:)236 1658 y
Fi(>>>)45 b(def)f(echo\(value=None\):)236 1750 y(...)224
b(print)44 b("Execution)f(starts)h(when)g('next\(\)')f(is)i(called)f
(for)g(the)g(first)g(time.")236 1841 y(...)224 b(try:)236
1932 y(...)403 b(while)44 b(True:)236 2024 y(...)583
b(try:)236 2115 y(...)762 b(value)44 b(=)h(\(yield)e(value\))236
2206 y(...)583 b(except)43 b(GeneratorExit:)236 2298
y(...)762 b(#)45 b(never)f(catch)g(GeneratorExit)236
2389 y(...)762 b(raise)236 2480 y(...)583 b(except)43
b(Exception,)h(e:)236 2572 y(...)762 b(value)44 b(=)h(e)236
2663 y(...)224 b(finally:)236 2754 y(...)403 b(print)44
b("Don't)g(forget)g(to)g(clean)g(up)h(when)f('close\(\)')f(is)i
(called.")236 2846 y(...)236 2937 y(>>>)g(generator)e(=)i(echo\(1\))236
3028 y(>>>)g(print)f(generator.next\(\))236 3120 y(Execution)g(starts)f
(when)i('next\(\)')e(is)i(called)e(for)i(the)f(first)g(time.)236
3211 y(1)236 3302 y(>>>)h(print)f(generator.next\(\))236
3394 y(None)236 3485 y(>>>)h(print)f(generator.send\(2\))236
3576 y(2)236 3668 y(>>>)h(generator.throw\(TypeError,)40
b("spam"\))236 3759 y(TypeError\('spam',\))236 3850 y(>>>)45
b(generator.close\(\))236 3942 y(Don't)f(forget)g(to)h(clean)f(up)g
(when)g('close\(\)')f(is)i(called.)0 4229 y Fr(See)21
b(Also:)0 4376 y Ft(PEP)g(0342,)d(\223)p Fq(Cor)l(outines)i(via)g
(Enhanced)e(Gener)o(ator)o(s)p Ft(\224)208 4475 y(The)h(proposal)g(to)h
(enhance)f(the)h(API)h(and)f(syntax)f(of)h(generators,)e(making)h(them)
h(usable)g(as)h(simple)f(coroutines.)0 4803 y Fm(5.3)121
b(Pr)r(imar)r(ies)0 5035 y Ft(Primaries)20 b(represent)f(the)h(most)g
(tightly)g(bound)e(operations)h(of)h(the)g(language.)j(Their)d(syntax)f
(is:)216 5181 y Fo(primary)98 b Ft(::=)i Fo(atom)49 b(|)g(attributeref)
f(|)i(subscription)d(|)j(slicing)e(|)i(call)p 0 5549
3901 4 v 0 5649 a Fp(5.3.)i(Pr)q(imar)q(ies)3266 b(43)p
eop end
%%Page: 44 50
TeXDict begin 44 49 bop 0 83 a Fk(5.3.1)100 b(Attr)q(ib)n(ute)29
b(ref)m(erences)0 286 y Ft(An)20 b(attrib)n(ute)g(reference)f(is)i(a)f
(primary)f(follo)n(wed)g(by)g(a)i(period)e(and)h(a)g(name:)216
432 y Fo(attributeref)97 b Ft(::=)j Fo(primary)48 b(".")i(identifier)0
580 y Ft(The)20 b(primary)g(must)g(e)n(v)n(aluate)g(to)h(an)g(object)f
(of)g(a)h(type)g(that)g(supports)e(attrib)n(ute)i(references,)e(e.g.,)h
(a)h(module,)e(list,)j(or)f(an)f(instance.)0 679 y(This)27
b(object)f(is)h(then)f(ask)o(ed)g(to)h(produce)d(the)j(attrib)n(ute)f
(whose)g(name)g(is)h(the)g(identi\002er)-5 b(.)43 b(If)27
b(this)g(attrib)n(ute)f(is)h(not)f(a)n(v)n(ailable,)i(the)0
779 y(e)o(xception)22 b Fo(AttributeError)g Ft(is)j(raised.)36
b(Otherwise,)25 b(the)f(type)f(and)h(v)n(alue)f(of)h(the)g(object)f
(produced)f(is)j(determined)d(by)i(the)0 879 y(object.)g(Multiple)c(e)n
(v)n(aluations)f(of)h(the)g(same)g(attrib)n(ute)g(reference)f(may)g
(yield)h(dif)n(ferent)f(objects.)0 1163 y Fk(5.3.2)100
b(Subscr)q(iptions)0 1366 y Ft(A)21 b(subscription)d(selects)j(an)g
(item)f(of)g(a)g(sequence)f(\(string,)h(tuple)g(or)f(list\))i(or)f
(mapping)f(\(dictionary\))e(object:)216 1512 y Fo(subscription)97
b Ft(::=)j Fo(primary)48 b("[")i(expression_list)d("]")0
1660 y Ft(The)20 b(primary)e(must)j(e)n(v)n(aluate)e(to)h(an)g(object)g
(of)g(a)h(sequence)e(or)h(mapping)e(type.)0 1807 y(If)30
b(the)h(primary)d(is)k(a)f(mapping,)f(the)h(e)o(xpression)e(list)i
(must)g(e)n(v)n(aluate)e(to)i(an)f(object)g(whose)g(v)n(alue)g(is)h
(one)f(of)g(the)g(k)o(e)o(ys)g(of)h(the)0 1907 y(mapping,)21
b(and)h(the)h(subscription)e(selects)j(the)e(v)n(alue)g(in)h(the)g
(mapping)e(that)h(corresponds)f(to)i(that)f(k)o(e)o(y)-5
b(.)32 b(\(The)22 b(e)o(xpression)f(list)j(is)f(a)0 2006
y(tuple)d(e)o(xcept)f(if)h(it)h(has)g(e)o(xactly)e(one)h(item.\))0
2153 y(If)e(the)g(primary)f(is)i(a)g(sequence,)e(the)h(e)o(xpression)f
(\(list\))h(must)h(e)n(v)n(aluate)e(to)h(a)h(plain)f(inte)o(ger)-5
b(.)23 b(If)c(this)f(v)n(alue)g(is)h(ne)o(gati)n(v)o(e,)d(the)i(length)
g(of)0 2253 y(the)i(sequence)g(is)h(added)e(to)i(it)g(\(so)f(that,)g
(e.g.,)g Fo(x[-1])g Ft(selects)h(the)f(last)i(item)e(of)g
Fo(x)p Ft(.\))26 b(The)20 b(resulting)f(v)n(alue)h(must)g(be)g(a)h
(nonne)o(gati)n(v)o(e)0 2352 y(inte)o(ger)g(less)j(than)d(the)i(number)
d(of)i(items)h(in)f(the)h(sequence,)e(and)h(the)g(subscription)f
(selects)i(the)f(item)h(whose)f(inde)o(x)f(is)i(that)f(v)n(alue)0
2452 y(\(counting)c(from)h(zero\).)0 2599 y(A)i(string')-5
b(s)20 b(items)h(are)f(characters.)k(A)c(character)f(is)i(not)f(a)h
(separate)f(data)g(type)f(b)n(ut)i(a)f(string)g(of)g(e)o(xactly)f(one)h
(character)-5 b(.)0 2884 y Fk(5.3.3)100 b(Slicings)0
3087 y Ft(A)19 b(slicing)f(selects)h(a)g(range)e(of)h(items)h(in)f(a)h
(sequence)e(object)h(\(e.g.,)g(a)g(string,)g(tuple)g(or)g(list\).)25
b(Slicings)19 b(may)f(be)g(used)g(as)h(e)o(xpressions)0
3186 y(or)h(as)h(tar)o(gets)e(in)i(assignment)e(or)h
Fo(del)g Ft(statements.)25 b(The)20 b(syntax)g(for)f(a)i(slicing:)216
3330 y Fo(slicing)546 b Ft(::=)100 b Fo(simple_slicing)47
b(|)j(extended_slicing)216 3429 y(simple_slicing)196
b Ft(::=)100 b Fo(primary)49 b("[")g(short_slice)f("]")216
3529 y(extended_slicing)96 b Ft(::=)k Fo(primary)49 b("[")g(slice_list)
f("]")216 3628 y(slice_list)396 b Ft(::=)100 b Fo(slice_item)48
b(\(",")h(slice_item\))2652 3643 y(*)2750 3628 y([","])216
3728 y(slice_item)396 b Ft(::=)100 b Fo(expression)48
b(|)i(proper_slice)d(|)j(ellipsis)216 3828 y(proper_slice)296
b Ft(::=)100 b Fo(short_slice)48 b(|)h(long_slice)216
3927 y(short_slice)346 b Ft(::=)100 b Fo([lower_bound])47
b(":")j([upper_bound])216 4027 y(long_slice)396 b Ft(::=)100
b Fo(short_slice)48 b(":")h([stride])216 4127 y(lower_bound)346
b Ft(::=)100 b Fo(expression)216 4226 y(upper_bound)346
b Ft(::=)100 b Fo(expression)216 4326 y(stride)596 b
Ft(::=)100 b Fo(expression)216 4425 y(ellipsis)496 b
Ft(::=)100 b Fo("...")0 4567 y Ft(There)21 b(is)h(ambiguity)e(in)i(the)
f(formal)g(syntax)f(here:)28 b(an)o(ything)19 b(that)j(looks)f(lik)o(e)
h(an)f(e)o(xpression)f(list)j(also)e(looks)g(lik)o(e)h(a)g(slice)g
(list,)h(so)0 4667 y(an)o(y)d(subscription)f(can)i(be)f(interpreted)f
(as)j(a)f(slicing.)27 b(Rather)20 b(than)h(further)e(complicating)g
(the)h(syntax,)g(this)i(is)f(disambiguated)e(by)0 4767
y(de\002ning)k(that)h(in)h(this)g(case)f(the)h(interpretation)d(as)j(a)
g(subscription)d(tak)o(es)j(priority)e(o)o(v)o(er)g(the)h
(interpretation)e(as)j(a)g(slicing)f(\(this)h(is)0 4866
y(the)c(case)h(if)g(the)f(slice)h(list)g(contains)f(no)g(proper)e
(slice)j(nor)f(ellipses\).)28 b(Similarly)-5 b(,)21 b(when)g(the)g
(slice)h(list)g(has)g(e)o(xactly)e(one)h(short)g(slice)0
4966 y(and)f(no)f(trailing)h(comma,)f(the)h(interpretation)e(as)j(a)g
(simple)f(slicing)g(tak)o(es)h(priority)d(o)o(v)o(er)h(that)i(as)f(an)h
(e)o(xtended)d(slicing.)0 5113 y(The)e(semantics)g(for)f(a)i(simple)f
(slicing)g(are)g(as)h(follo)n(ws.)23 b(The)16 b(primary)e(must)i(e)n(v)
n(aluate)f(to)i(a)f(sequence)f(object.)23 b(The)16 b(lo)n(wer)f(and)h
(upper)0 5212 y(bound)g(e)o(xpressions,)i(if)g(present,)g(must)g(e)n(v)
n(aluate)g(to)g(plain)g(inte)o(gers;)g(def)o(aults)g(are)g(zero)g(and)g
(the)g Fo(sys.maxint)p Ft(,)f(respecti)n(v)o(ely)-5 b(.)23
b(If)0 5312 y(either)c(bound)f(is)j(ne)o(gati)n(v)o(e,)c(the)j
(sequence')-5 b(s)19 b(length)g(is)i(added)d(to)i(it.)26
b(The)19 b(slicing)h(no)n(w)f(selects)i(all)f(items)g(with)g(inde)o(x)f
Fq(k)j Ft(such)d(that)h Fq(i)p 0 5549 3901 4 v 0 5649
a Fp(44)2917 b(Chapter)23 b(5.)52 b(Expressions)p eop
end
%%Page: 45 51
TeXDict begin 45 50 bop 0 83 a Fo(<=)49 b Fq(k)j Fo(<)d
Fq(j)22 b Ft(where)e Fq(i)h Ft(and)g Fq(j)g Ft(are)g(the)g(speci\002ed)
g(lo)n(wer)f(and)g(upper)g(bounds.)25 b(This)c(may)g(be)g(an)f(empty)g
(sequence.)26 b(It)21 b(is)h(not)f(an)g(error)0 183 y(if)f
Fq(i)h Ft(or)f Fq(j)h Ft(lie)g(outside)e(the)i(range)e(of)h(v)n(alid)f
(inde)o(x)o(es)g(\(such)h(items)h(don')o(t)d(e)o(xist)i(so)h(the)o(y)e
(aren')o(t)g(selected\).)0 330 y(The)f(semantics)h(for)e(an)i(e)o
(xtended)d(slicing)j(are)f(as)h(follo)n(ws.)24 b(The)18
b(primary)f(must)i(e)n(v)n(aluate)e(to)i(a)g(mapping)d(object,)i(and)g
(it)h(is)h(inde)o(x)o(ed)0 429 y(with)25 b(a)g(k)o(e)o(y)g(that)g(is)g
(constructed)f(from)f(the)i(slice)h(list,)h(as)e(follo)n(ws.)39
b(If)25 b(the)g(slice)g(list)h(contains)e(at)i(least)f(one)g(comma,)f
(the)h(k)o(e)o(y)g(is)0 529 y(a)g(tuple)f(containing)f(the)i(con)m(v)o
(ersion)d(of)i(the)h(slice)g(items;)j(otherwise,)d(the)g(con)m(v)o
(ersion)d(of)i(the)h(lone)f(slice)h(item)g(is)h(the)e(k)o(e)o(y)-5
b(.)38 b(The)0 628 y(con)m(v)o(ersion)15 b(of)j(a)h(slice)f(item)g
(that)h(is)g(an)f(e)o(xpression)e(is)j(that)f(e)o(xpression.)23
b(The)17 b(con)m(v)o(ersion)f(of)h(an)h(ellipsis)h(slice)g(item)f(is)h
(the)f(b)n(uilt-in)0 728 y Fo(Ellipsis)f Ft(object.)24
b(The)18 b(con)m(v)o(ersion)e(of)i(a)h(proper)d(slice)j(is)h(a)f(slice)
g(object)f(\(see)g(section)g(3.2\))g(whose)g Fo(start)p
Ft(,)g Fo(stop)g Ft(and)g Fo(step)0 828 y Ft(attrib)n(utes)26
b(are)h(the)f(v)n(alues)g(of)g(the)g(e)o(xpressions)f(gi)n(v)o(en)g(as)
i(lo)n(wer)f(bound,)g(upper)f(bound)f(and)i(stride,)i(respecti)n(v)o
(ely)-5 b(,)25 b(substituting)0 927 y Fo(None)20 b Ft(for)g(missing)g
(e)o(xpressions.)0 1212 y Fk(5.3.4)100 b(Calls)0 1415
y Ft(A)21 b(call)f(calls)h(a)g(callable)f(object)f(\(e.g.,)h(a)g
(function\))e(with)j(a)f(possibly)g(empty)f(series)i(of)f(ar)o
(guments:)216 1558 y Fo(call)896 b Ft(::=)99 b Fo(primary)49
b("\(")g([argument_list)e([","])1554 1658 y(|)j(expression)e
(genexpr_for])f("\)")216 1758 y(argument_list)446 b Ft(::=)99
b Fo(positional_arguments)46 b([",")j(keyword_arguments])1554
1857 y([",")g(")1853 1872 y(*)1903 1857 y(")g(expression])1554
1957 y([",")g(")1853 1972 y(**)1953 1957 y(")g(expression])1504
2056 y(|)h(keyword_arguments)d([",")i(")2800 2071 y(*)2850
2056 y(")g(expression])1554 2156 y([",")g(")1853 2171
y(**)1953 2156 y(")g(expression])1504 2256 y(|)h(")1654
2271 y(*)1704 2256 y(")f(expression)f([",")h(")2650 2271
y(**)2750 2256 y(")g(expression])1504 2355 y(|)h(")1654
2370 y(**)1754 2355 y(")f(expression)216 2455 y(positional_arguments)96
b Ft(::=)j Fo(expression)48 b(\(",")h(expression\))2851
2470 y(*)216 2555 y(keyword_arguments)246 b Ft(::=)99
b Fo(keyword_item)48 b(\(",")h(keyword_item\))3051 2570
y(*)216 2654 y(keyword_item)496 b Ft(::=)99 b Fo(identifier)48
b("=")i(expression)0 2796 y Ft(A)21 b(trailing)e(comma)g(may)h(be)g
(present)g(after)g(the)g(positional)f(and)h(k)o(e)o(yw)o(ord)e(ar)o
(guments)g(b)n(ut)i(does)g(not)g(af)n(fect)g(the)g(semantics.)0
2943 y(The)h(primary)e(must)i(e)n(v)n(aluate)f(to)h(a)h(callable)e
(object)h(\(user)n(-de\002ned)e(functions,)g(b)n(uilt-in)i(functions,)e
(methods)h(of)h(b)n(uilt-in)f(objects,)0 3043 y(class)26
b(objects,)g(methods)e(of)g(class)i(instances,)g(and)f(certain)f(class)
i(instances)f(themselv)o(es)f(are)h(callable;)j(e)o(xtensions)c(may)g
(de\002ne)0 3142 y(additional)d(callable)i(object)f(types\).)32
b(All)24 b(ar)o(gument)c(e)o(xpressions)h(are)i(e)n(v)n(aluated)e
(before)h(the)h(call)g(is)g(attempted.)32 b(Please)23
b(refer)f(to)0 3242 y(section)e(7.6)f(for)h(the)g(syntax)g(of)g(formal)
f(parameter)f(lists.)0 3389 y(If)k(k)o(e)o(yw)o(ord)f(ar)o(guments)g
(are)h(present,)g(the)o(y)g(are)h(\002rst)g(con)m(v)o(erted)d(to)i
(positional)g(ar)o(guments,)f(as)i(follo)n(ws.)32 b(First,)23
b(a)g(list)h(of)e(un\002lled)0 3489 y(slots)d(is)g(created)e(for)h(the)
g(formal)f(parameters.)23 b(If)17 b(there)h(are)g(N)h(positional)e(ar)o
(guments,)f(the)o(y)h(are)h(placed)f(in)i(the)f(\002rst)h(N)f(slots.)25
b(Ne)o(xt,)0 3588 y(for)e(each)f(k)o(e)o(yw)o(ord)g(ar)o(gument,)f(the)
i(identi\002er)g(is)h(used)f(to)h(determine)d(the)j(corresponding)19
b(slot)24 b(\(if)f(the)g(identi\002er)g(is)h(the)f(same)h(as)0
3688 y(the)c(\002rst)h(formal)e(parameter)f(name,)h(the)h(\002rst)h
(slot)g(is)f(used,)g(and)f(so)i(on\).)j(If)c(the)g(slot)g(is)h(already)
e(\002lled,)h(a)h Fo(TypeError)d Ft(e)o(xception)0 3787
y(is)h(raised.)25 b(Otherwise,)18 b(the)g(v)n(alue)g(of)g(the)h(ar)o
(gument)d(is)j(placed)f(in)g(the)h(slot,)g(\002lling)f(it)h(\(e)n(v)o
(en)e(if)i(the)f(e)o(xpression)f(is)i Fo(None)p Ft(,)g(it)g(\002lls)h
(the)0 3887 y(slot\).)25 b(When)19 b(all)h(ar)o(guments)d(ha)n(v)o(e)i
(been)f(processed,)h(the)g(slots)h(that)f(are)h(still)g(un\002lled)f
(are)g(\002lled)h(with)f(the)g(corresponding)d(def)o(ault)0
3987 y(v)n(alue)k(from)h(the)g(function)e(de\002nition.)27
b(\(Def)o(ault)20 b(v)n(alues)h(are)g(calculated,)f(once,)h(when)f(the)
i(function)d(is)j(de\002ned;)f(thus,)g(a)h(mutable)0
4086 y(object)e(such)f(as)i(a)g(list)g(or)f(dictionary)e(used)i(as)h
(def)o(ault)e(v)n(alue)g(will)i(be)f(shared)f(by)h(all)h(calls)g(that)f
(don')o(t)e(specify)i(an)g(ar)o(gument)d(v)n(alue)0 4186
y(for)j(the)g(corresponding)d(slot;)k(this)g(should)e(usually)h(be)g(a)
n(v)n(oided.\))k(If)c(there)g(are)h(an)o(y)e(un\002lled)h(slots)h(for)f
(which)f(no)h(def)o(ault)g(v)n(alue)g(is)0 4286 y(speci\002ed,)f(a)i
Fo(TypeError)e Ft(e)o(xception)f(is)j(raised.)j(Otherwise,)c(the)g
(list)h(of)e(\002lled)i(slots)f(is)h(used)f(as)h(the)e(ar)o(gument)f
(list)j(for)e(the)h(call.)0 4432 y(If)d(there)h(are)f(more)g
(positional)g(ar)o(guments)e(than)i(there)g(are)h(formal)e(parameter)g
(slots,)j(a)f Fo(TypeError)f Ft(e)o(xception)e(is)k(raised,)e(unless)0
4532 y(a)23 b(formal)e(parameter)g(using)h(the)g(syntax)g(`)1254
4547 y Fo(*)1304 4532 y(identifier)p Ft(')f(is)i(present;)g(in)f(this)h
(case,)h(that)e(formal)g(parameter)e(recei)n(v)o(es)i(a)h(tuple)0
4632 y(containing)18 b(the)i(e)o(xcess)h(positional)e(ar)o(guments)f
(\(or)i(an)g(empty)f(tuple)h(if)g(there)g(were)g(no)g(e)o(xcess)g
(positional)f(ar)o(guments\).)0 4779 y(If)e(an)o(y)f(k)o(e)o(yw)o(ord)f
(ar)o(gument)g(does)i(not)g(correspond)d(to)j(a)h(formal)e(parameter)f
(name,)i(a)h Fo(TypeError)e Ft(e)o(xception)f(is)j(raised,)f(unless)g
(a)0 4878 y(formal)i(parameter)f(using)i(the)g(syntax)f(`)1182
4893 y Fo(**)1282 4878 y(identifier)p Ft(')f(is)j(present;)e(in)h(this)
h(case,)f(that)g(formal)f(parameter)g(recei)n(v)o(es)g(a)h(dictio-)0
4978 y(nary)e(containing)g(the)h(e)o(xcess)g(k)o(e)o(yw)o(ord)f(ar)o
(guments)f(\(using)h(the)i(k)o(e)o(yw)o(ords)d(as)j(k)o(e)o(ys)f(and)g
(the)g(ar)o(gument)e(v)n(alues)i(as)h(corresponding)0
5077 y(v)n(alues\),)f(or)h(a)h(\(ne)n(w\))e(empty)g(dictionary)g(if)h
(there)g(were)g(no)g(e)o(xcess)g(k)o(e)o(yw)o(ord)e(ar)o(guments.)0
5224 y(If)23 b(the)g(syntax)f(`)472 5239 y Fo(*)522 5224
y(expression)p Ft(')f(appears)h(in)h(the)g(function)e(call,)j(`)p
Fo(expression)p Ft(')d(must)i(e)n(v)n(aluate)f(to)h(a)g(sequence.)32
b(Elements)0 5324 y(from)16 b(this)h(sequence)f(are)g(treated)h(as)g
(if)g(the)o(y)f(were)h(additional)e(positional)h(ar)o(guments;)g(if)h
(there)f(are)h(postional)f(ar)o(guments)f Fq(x1)p Ft(,...,)p
Fq(xN)p 0 5549 3901 4 v 0 5649 a Fp(5.3.)52 b(Pr)q(imar)q(ies)3266
b(45)p eop end
%%Page: 46 52
TeXDict begin 46 51 bop 0 83 a Ft(,)26 b(and)f(`)p Fo(expression)p
Ft(')f(e)n(v)n(aluates)g(to)i(a)g(sequence)f Fq(y1)p
Ft(,...,)p Fq(yM)s Ft(,)f(this)i(is)h(equi)n(v)n(alent)d(to)h(a)h(call)
g(with)g(M+N)g(positional)f(ar)o(guments)0 183 y Fq(x1)p
Ft(,...,)p Fq(xN)5 b Ft(,)p Fq(y1)p Ft(,...,)p Fq(yM)s
Ft(.)0 330 y(A)24 b(consequence)e(of)h(this)h(is)h(that)f(although)e
(the)h(`)1467 345 y Fo(*)1517 330 y(expression)p Ft(')f(syntax)h
(appears)g Fq(after)h Ft(an)o(y)f(k)o(e)o(yw)o(ord)e(ar)o(guments,)i
(it)h(is)h(pro-)0 429 y(cessed)20 b Fq(befor)m(e)g Ft(the)g(k)o(e)o(yw)
o(ord)f(ar)o(guments)f(\(and)h(the)h(`)1581 444 y Fo(**)1681
429 y(expression)p Ft(')e(ar)o(gument,)g(if)i(an)o(y)g(\226)g(see)h
(belo)n(w\).)j(So:)236 667 y Fi(>>>)45 b(def)f(f\(a,)g(b\):)236
759 y(...)89 b(print)44 b(a,)h(b)236 850 y(...)236 941
y(>>>)g(f\(b=1,)729 954 y(*)774 941 y(\(2,\)\))236 1033
y(2)g(1)236 1124 y(>>>)g(f\(a=1,)729 1137 y(*)774 1124
y(\(2,\)\))236 1215 y(Traceback)f(\(most)g(recent)f(call)i(last\):)326
1307 y(File)f("<stdin>",)f(line)h(1,)h(in)f(?)236 1398
y(TypeError:)f(f\(\))i(got)f(multiple)g(values)f(for)i(keyword)e
(argument)h('a')236 1489 y(>>>)h(f\(1,)640 1502 y(*)685
1489 y(\(2,\)\))236 1581 y(1)g(2)0 1867 y Ft(It)22 b(is)g(unusual)f
(for)g(both)g(k)o(e)o(yw)o(ord)f(ar)o(guments)f(and)i(the)h(`)1690
1882 y Fo(*)1740 1867 y(expression)p Ft(')d(syntax)i(to)h(be)g(used)f
(in)h(the)f(same)h(call,)g(so)g(in)g(practice)0 1967
y(this)f(confusion)d(does)i(not)g(arise.)0 2114 y(If)g(the)g(syntax)f
(`)463 2129 y Fo(**)563 2114 y(expression)p Ft(')f(appears)h(in)h(the)g
(function)f(call,)h(`)p Fo(expression)p Ft(')e(must)i(e)n(v)n(aluate)f
(to)h(a)h(\(subclass)f(of\))f(dictio-)0 2213 y(nary)-5
b(,)22 b(the)h(contents)f(of)h(which)g(are)g(treated)f(as)i(additional)
d(k)o(e)o(yw)o(ord)h(ar)o(guments.)31 b(In)23 b(the)g(case)g(of)g(a)g
(k)o(e)o(yw)o(ord)e(appearing)g(in)i(both)0 2313 y(`)p
Fo(expression)p Ft(')18 b(and)i(as)h(an)f(e)o(xplicit)f(k)o(e)o(yw)o
(ord)g(ar)o(gument,)e(a)k Fo(TypeError)e Ft(e)o(xception)f(is)j
(raised.)0 2460 y(F)o(ormal)i(parameters)f(using)h(the)g(syntax)g(`)
1249 2475 y Fo(*)1299 2460 y(identifier)p Ft(')f(or)h(`)1970
2475 y Fo(**)2070 2460 y(identifier)p Ft(')e(cannot)h(be)i(used)f(as)h
(positional)f(ar)o(gument)0 2559 y(slots)f(or)g(as)g(k)o(e)o(yw)o(ord)e
(ar)o(gument)f(names.)29 b(F)o(ormal)21 b(parameters)g(using)g(the)h
(syntax)f(`)p Fo(\(sublist\))p Ft(')e(cannot)i(be)h(used)f(as)h(k)o(e)o
(yw)o(ord)0 2659 y(ar)o(gument)27 b(names;)33 b(the)28
b(outermost)g(sublist)h(corresponds)e(to)i(a)g(single)g(unnamed)e(ar)o
(gument)f(slot,)32 b(and)c(the)h(ar)o(gument)d(v)n(alue)j(is)0
2759 y(assigned)20 b(to)g(the)g(sublist)h(using)e(the)i(usual)f(tuple)g
(assignment)f(rules)h(after)g(all)h(other)e(parameter)g(processing)g
(is)i(done.)0 2905 y(A)h(call)h(al)o(w)o(ays)f(returns)f(some)h(v)n
(alue,)g(possibly)f Fo(None)p Ft(,)h(unless)g(it)h(raises)f(an)g(e)o
(xception.)28 b(Ho)n(w)22 b(this)h(v)n(alue)e(is)i(computed)d(depends)0
3005 y(on)g(the)g(type)g(of)g(the)g(callable)g(object.)0
3152 y(If)g(it)h(is\227)0 3382 y Fr(a)f(user)m(-de\002ned)h(function:)
41 b Ft(The)20 b(code)f(block)h(for)g(the)g(function)f(is)i(e)o(x)o
(ecuted,)e(passing)h(it)h(the)g(ar)o(gument)d(list.)26
b(The)21 b(\002rst)g(thing)f(the)208 3481 y(code)k(block)f(will)j(do)e
(is)i(bind)e(the)h(formal)f(parameters)f(to)i(the)g(ar)o(guments;)g
(this)g(is)h(described)d(in)i(section)g(7.6.)38 b(When)25
b(the)208 3581 y(code)19 b(block)g(e)o(x)o(ecutes)g(a)i
Fo(return)f Ft(statement,)f(this)i(speci\002es)g(the)f(return)f(v)n
(alue)g(of)h(the)h(function)d(call.)0 3747 y Fr(a)i(b)n(uilt-in)h
(function)f(or)g(method:)41 b Ft(The)23 b(result)f(is)i(up)e(to)h(the)g
(interpreter;)f(see)i(the)e Fq(Python)g(Libr)o(ary)h(Refer)m(ence)f
Ft(for)g(the)h(descrip-)208 3847 y(tions)d(of)g(b)n(uilt-in)f
(functions)g(and)h(methods.)0 4013 y Fr(a)g(class)h(object:)40
b Ft(A)21 b(ne)n(w)f(instance)f(of)h(that)h(class)g(is)g(returned.)0
4179 y Fr(a)f(class)h(instance)f(method:)41 b Ft(The)21
b(corresponding)d(user)n(-de\002ned)i(function)g(is)i(called,)g(with)g
(an)f(ar)o(gument)e(list)k(that)e(is)i(one)e(longer)208
4278 y(than)e(the)h(ar)o(gument)e(list)k(of)e(the)g(call:)25
b(the)c(instance)e(becomes)h(the)g(\002rst)h(ar)o(gument.)0
4445 y Fr(a)f(class)h(instance:)41 b Ft(The)25 b(class)i(must)e
(de\002ne)h(a)g Fo(__call__\(\))e Ft(method;)j(the)f(ef)n(fect)f(is)i
(then)e(the)g(same)h(as)h(if)f(that)f(method)g(w)o(as)208
4544 y(called.)0 4872 y Fm(5.4)121 b(The)34 b(po)n(w)o(er)h(oper)o
(ator)0 5104 y Ft(The)20 b(po)n(wer)f(operator)f(binds)i(more)g
(tightly)f(than)h(unary)f(operators)f(on)i(its)h(left;)g(it)g(binds)f
(less)h(tightly)e(than)h(unary)f(operators)g(on)h(its)0
5204 y(right.)k(The)c(syntax)g(is:)216 5350 y Fo(power)99
b Ft(::=)g Fo(primary)49 b([")1256 5365 y(**)1356 5350
y(")g(u_expr])p 0 5549 3901 4 v 0 5649 a Fp(46)2917 b(Chapter)23
b(5.)52 b(Expressions)p eop end
%%Page: 47 53
TeXDict begin 47 52 bop 0 83 a Ft(Thus,)18 b(in)h(an)g(unparenthesized)
c(sequence)j(of)g(po)n(wer)g(and)g(unary)f(operators,)g(the)i
(operators)e(are)i(e)n(v)n(aluated)e(from)h(right)g(to)h(left)f(\(this)
0 183 y(does)i(not)g(constrain)f(the)h(e)n(v)n(aluation)f(order)g(for)g
(the)h(operands\).)0 330 y(The)f(po)n(wer)f(operator)f(has)i(the)g
(same)g(semantics)g(as)h(the)f(b)n(uilt-in)f Fo(pow\(\))h
Ft(function,)e(when)h(called)h(with)g(tw)o(o)g(ar)o(guments:)k(it)d
(yields)0 429 y(its)26 b(left)f(ar)o(gument)e(raised)i(to)g(the)g(po)n
(wer)f(of)h(its)h(right)e(ar)o(gument.)37 b(The)25 b(numeric)f(ar)o
(guments)f(are)i(\002rst)g(con)m(v)o(erted)e(to)i(a)g(common)0
529 y(type.)f(The)c(result)h(type)e(is)i(that)g(of)f(the)g(ar)o
(guments)e(after)i(coercion.)0 676 y(W)m(ith)27 b(mix)o(ed)f(operand)f
(types,)j(the)f(coercion)e(rules)i(for)f(binary)g(arithmetic)g
(operators)g(apply)-5 b(.)43 b(F)o(or)27 b(int)g(and)f(long)g(int)i
(operands,)0 775 y(the)23 b(result)h(has)g(the)f(same)h(type)f(as)h
(the)f(operands)f(\(after)h(coercion\))e(unless)j(the)f(second)g(ar)o
(gument)e(is)j(ne)o(gati)n(v)o(e;)f(in)h(that)g(case,)g(all)0
875 y(ar)o(guments)16 b(are)j(con)m(v)o(erted)d(to)i(\003oat)h(and)f(a)
h(\003oat)g(result)f(is)i(deli)n(v)o(ered.)i(F)o(or)c(e)o(xample,)g
Fo(10)2621 890 y(**)2721 875 y(2)g Ft(returns)f Fo(100)p
Ft(,)i(b)n(ut)f Fo(10)3451 890 y(**)3551 875 y(-2)g Ft(returns)0
975 y Fo(0.01)p Ft(.)30 b(\(This)22 b(last)h(feature)e(w)o(as)i(added)e
(in)h(Python)f(2.2.)29 b(In)22 b(Python)f(2.1)g(and)h(before,)f(if)h
(both)f(ar)o(guments)f(were)i(of)g(inte)o(ger)f(types)0
1074 y(and)f(the)g(second)f(ar)o(gument)f(w)o(as)j(ne)o(gati)n(v)o(e,)d
(an)i(e)o(xception)e(w)o(as)j(raised\).)0 1221 y(Raising)29
b Fo(0.0)f Ft(to)h(a)g(ne)o(gati)n(v)o(e)e(po)n(wer)g(results)i(in)g(a)
g Fo(ZeroDivisionError)p Ft(.)47 b(Raising)29 b(a)g(ne)o(gati)n(v)o(e)d
(number)h(to)i(a)g(fractional)0 1321 y(po)n(wer)19 b(results)i(in)f(a)h
Fo(ValueError)p Ft(.)0 1648 y Fm(5.5)121 b(Unar)t(y)33
b(ar)r(ithmetic)h(oper)o(ations)0 1881 y Ft(All)21 b(unary)e
(arithmetic)g(\(and)g(bit-wise\))h(operations)f(ha)n(v)o(e)g(the)i
(same)f(priority:)216 2027 y Fo(u_expr)98 b Ft(::=)i
Fo(power)49 b(|)g("-")h(u_expr)e(|)i("+")f(u_expr)g(|)h("\230")f
(u_expr)0 2175 y Ft(The)20 b(unary)f Fo(-)h Ft(\(minus\))f(operator)g
(yields)h(the)g(ne)o(gation)e(of)i(its)h(numeric)e(ar)o(gument.)0
2321 y(The)h(unary)f Fo(+)h Ft(\(plus\))g(operator)e(yields)i(its)h
(numeric)e(ar)o(gument)f(unchanged.)0 2468 y(The)g(unary)f
Fo(\230)i Ft(\(in)m(v)o(ert\))d(operator)g(yields)i(the)h(bit-wise)f
(in)m(v)o(ersion)e(of)i(its)i(plain)e(or)g(long)f(inte)o(ger)g(ar)o
(gument.)22 b(The)c(bit-wise)h(in)m(v)o(ersion)0 2568
y(of)h Fo(x)g Ft(is)i(de\002ned)d(as)i Fo(-\(x+1\))p
Ft(.)j(It)d(only)e(applies)h(to)g(inte)o(gral)f(numbers.)0
2715 y(In)h(all)h(three)e(cases,)i(if)g(the)f(ar)o(gument)e(does)i(not)
f(ha)n(v)o(e)h(the)g(proper)f(type,)g(a)i Fo(TypeError)e
Ft(e)o(xception)f(is)j(raised.)0 3042 y Fm(5.6)121 b(Binar)t(y)32
b(ar)r(ithmetic)i(oper)o(ations)0 3275 y Ft(The)17 b(binary)e
(arithmetic)i(operations)e(ha)n(v)o(e)i(the)g(con)m(v)o(entional)d
(priority)h(le)n(v)o(els.)24 b(Note)17 b(that)g(some)g(of)g(these)g
(operations)f(also)h(apply)f(to)0 3375 y(certain)21 b(non-numeric)e
(types.)30 b(Apart)22 b(from)e(the)i(po)n(wer)f(operator)m(,)f(there)i
(are)g(only)f(tw)o(o)h(le)n(v)o(els,)g(one)f(for)h(multiplicati)n(v)o
(e)e(operators)0 3474 y(and)g(one)f(for)h(additi)n(v)o(e)f(operators:)
216 3618 y Fo(m_expr)98 b Ft(::=)i Fo(u_expr)49 b(|)g(m_expr)g(")1654
3633 y(*)1704 3618 y(")g(u_expr)g(|)h(m_expr)e("//")h(u_expr)g(|)h
(m_expr)e("/")i(u_expr)807 3717 y(|)g(m_expr)e("\045")i(u_expr)216
3817 y(a_expr)98 b Ft(::=)i Fo(m_expr)49 b(|)g(a_expr)g("+")g(m_expr)g
(|)h(a_expr)e("-")h(m_expr)0 4002 y Ft(The)154 4017 y
Fo(*)228 4002 y Ft(\(multiplication\))22 b(operator)g(yields)i(the)g
(product)e(of)i(its)h(ar)o(guments.)34 b(The)24 b(ar)o(guments)e(must)i
(either)g(both)f(be)h(numbers,)f(or)0 4102 y(one)h(ar)o(gument)e(must)j
(be)f(an)h(inte)o(ger)e(\(plain)h(or)g(long\))f(and)h(the)h(other)e
(must)i(be)f(a)h(sequence.)37 b(In)24 b(the)h(former)e(case,)j(the)e
(numbers)0 4201 y(are)g(con)m(v)o(erted)e(to)i(a)g(common)f(type)g(and)
h(then)f(multiplied)g(together)-5 b(.)36 b(In)24 b(the)g(latter)g
(case,)i(sequence)d(repetition)g(is)i(performed;)e(a)0
4301 y(ne)o(gati)n(v)o(e)18 b(repetition)h(f)o(actor)h(yields)g(an)g
(empty)f(sequence.)0 4448 y(The)30 b Fo(/)h Ft(\(di)n(vision\))e(and)h
Fo(//)h Ft(\(\003oor)e(di)n(vision\))g(operators)g(yield)h(the)h
(quotient)e(of)h(their)h(ar)o(guments.)53 b(The)31 b(numeric)e(ar)o
(guments)0 4547 y(are)k(\002rst)g(con)m(v)o(erted)d(to)j(a)g(common)e
(type.)62 b(Plain)33 b(or)f(long)g(inte)o(ger)g(di)n(vision)g(yields)g
(an)h(inte)o(ger)f(of)g(the)h(same)g(type;)38 b(the)33
b(re-)0 4647 y(sult)i(is)g(that)g(of)f(mathematical)g(di)n(vision)f
(with)i(the)f(`\003oor')f(function)g(applied)h(to)g(the)h(result.)68
b(Di)n(vision)33 b(by)i(zero)e(raises)j(the)0 4747 y
Fo(ZeroDivisionError)18 b Ft(e)o(xception.)0 4893 y(The)27
b Fo(\045)h Ft(\(modulo\))d(operator)g(yields)j(the)f(remainder)e(from)
i(the)g(di)n(vision)f(of)i(the)f(\002rst)h(ar)o(gument)d(by)i(the)g
(second.)46 b(The)27 b(numeric)0 4993 y(ar)o(guments)17
b(are)h(\002rst)i(con)m(v)o(erted)c(to)j(a)g(common)e(type.)24
b(A)19 b(zero)f(right)g(ar)o(gument)f(raises)i(the)g
Fo(ZeroDivisionError)d Ft(e)o(xception.)0 5093 y(The)i(ar)o(guments)f
(may)h(be)g(\003oating)g(point)g(numbers,)f(e.g.,)h Fo(3.14\0450.7)f
Ft(equals)i Fo(0.34)f Ft(\(since)g Fo(3.14)h Ft(equals)f
Fo(4)3304 5108 y(*)3354 5093 y(0.7)49 b(+)g(0.34)p Ft(.\))0
5192 y(The)23 b(modulo)e(operator)g(al)o(w)o(ays)j(yields)f(a)g(result)
g(with)g(the)g(same)g(sign)g(as)h(its)g(second)e(operand)f(\(or)i
(zero\);)g(the)g(absolute)g(v)n(alue)f(of)p 0 5549 3901
4 v 0 5649 a Fp(5.5.)52 b(Unar)r(y)23 b(ar)q(ithmetic)h(oper)o(ations)
2601 b(47)p eop end
%%Page: 48 54
TeXDict begin 48 53 bop 0 83 a Ft(the)20 b(result)g(is)i(strictly)e
(smaller)g(than)g(the)g(absolute)g(v)n(alue)f(of)h(the)g(second)f
(operand)2435 53 y Fg(2)2466 83 y Ft(.)0 230 y(The)28
b(inte)o(ger)f(di)n(vision)g(and)g(modulo)g(operators)f(are)i
(connected)e(by)i(the)g(follo)n(wing)f(identity:)40 b
Fo(x)50 b(==)f(\(x/y\))3382 245 y(*)3432 230 y(y)g(+)g(\(x\045y\))p
Ft(.)0 330 y(Inte)o(ger)16 b(di)n(vision)g(and)g(modulo)g(are)h(also)g
(connected)f(with)h(the)g(b)n(uilt-in)g(function)e Fo(divmod\(\))p
Ft(:)23 b Fo(divmod\(x,)48 b(y\))h(==)h(\(x/y,)0 429
y(x\045y\))p Ft(.)30 b(These)21 b(identities)h(don')o(t)e(hold)h(for)h
(\003oating)f(point)g(numbers;)g(there)g(similar)h(identities)g(hold)f
(approximately)e(where)j Fo(x/y)0 529 y Ft(is)f(replaced)e(by)h
Fo(floor\(x/y\))f Ft(or)h Fo(floor\(x/y\))48 b(-)h(1)1788
499 y Fg(3)1821 529 y Ft(.)0 676 y(In)23 b(addition)e(to)i(performing)d
(the)j(modulo)f(operation)f(on)h(numbers,)g(the)h Fo(\045)g
Ft(operator)f(is)h(also)h(o)o(v)o(erloaded)c(by)i(string)h(and)f
(unicode)0 775 y(objects)d(to)h(perform)d(string)i(formatting)e(\(also)
j(kno)n(wn)e(as)i(interpolation\).)i(The)d(syntax)g(for)f(string)h
(formatting)f(is)i(described)e(in)i(the)0 875 y Fq(Python)f(Libr)o(ary)
h(Refer)m(ence)p Ft(,)g(section)f(\223Sequence)g(T)-7
b(ypes\224.)0 1022 y Fr(Depr)o(ecated)27 b(since)i(r)o(elease)f(2.3.)49
b Ft(The)28 b(\003oor)g(di)n(vision)g(operator)m(,)g(the)g(modulo)f
(operator)m(,)h(and)g(the)g Fo(divmod\(\))g Ft(function)f(are)0
1121 y(no)i(longer)f(de\002ned)g(for)g(comple)o(x)g(numbers.)50
b(Instead,)30 b(con)m(v)o(ert)d(to)j(a)f(\003oating)g(point)f(number)f
(using)i(the)g Fo(abs\(\))g Ft(function)e(if)0 1221 y(appropriate.)0
1368 y(The)32 b Fo(+)g Ft(\(addition\))e(operator)g(yields)i(the)g(sum)
g(of)f(its)i(ar)o(guments.)58 b(The)32 b(ar)o(guments)e(must)i(either)f
(both)g(be)h(numbers)f(or)g(both)0 1468 y(sequences)18
b(of)h(the)h(same)f(type.)24 b(In)19 b(the)h(former)d(case,)j(the)f
(numbers)f(are)h(con)m(v)o(erted)e(to)i(a)h(common)d(type)i(and)g(then)
g(added)f(together)-5 b(.)0 1567 y(In)20 b(the)g(latter)g(case,)h(the)f
(sequences)f(are)i(concatenated.)0 1714 y(The)26 b Fo(-)h
Ft(\(subtraction\))d(operator)g(yields)i(the)g(dif)n(ference)f(of)h
(its)h(ar)o(guments.)41 b(The)26 b(numeric)f(ar)o(guments)f(are)i
(\002rst)h(con)m(v)o(erted)d(to)i(a)0 1814 y(common)18
b(type.)0 2141 y Fm(5.7)121 b(Shifting)34 b(oper)o(ations)0
2374 y Ft(The)20 b(shifting)f(operations)g(ha)n(v)o(e)h(lo)n(wer)f
(priority)g(than)h(the)g(arithmetic)f(operations:)216
2520 y Fo(shift_expr)98 b Ft(::=)h Fo(a_expr)49 b(|)h(shift_expr)d(\()j
("<<")f(|)h(">>")f(\))g(a_expr)0 2668 y Ft(These)26 b(operators)e
(accept)h(plain)g(or)h(long)f(inte)o(gers)g(as)h(ar)o(guments.)40
b(The)25 b(ar)o(guments)f(are)h(con)m(v)o(erted)f(to)h(a)i(common)d
(type.)41 b(The)o(y)0 2767 y(shift)20 b(the)h(\002rst)g(ar)o(gument)c
(to)k(the)f(left)g(or)g(right)g(by)g(the)g(number)e(of)i(bits)h(gi)n(v)
o(en)e(by)g(the)i(second)e(ar)o(gument.)0 2914 y(A)27
b(right)f(shift)h(by)f Fq(n)h Ft(bits)g(is)h(de\002ned)e(as)h(di)n
(vision)f(by)g Fo(pow\(2,)p Fq(n)p Fo(\))p Ft(.)43 b(A)27
b(left)g(shift)g(by)g Fq(n)f Ft(bits)i(is)f(de\002ned)f(as)h
(multiplication)e(with)0 3014 y Fo(pow\(2,)p Fq(n)p Fo(\))p
Ft(;)e(for)f(plain)h(inte)o(gers)f(there)h(is)g(no)g(o)o(v)o(er\003o)n
(w)e(check)h(so)h(in)h(that)f(case)g(the)g(operation)e(drops)h(bits)h
(and)g(\003ips)g(the)g(sign)g(if)0 3113 y(the)d(result)g(is)i(not)d
(less)j(than)d Fo(pow\(2,31\))g Ft(in)i(absolute)e(v)n(alue.)25
b(Ne)o(gati)n(v)o(e)18 b(shift)i(counts)g(raise)g(a)h
Fo(ValueError)e Ft(e)o(xception.)0 3441 y Fm(5.8)121
b(Binar)t(y)32 b(bit-wise)i(oper)o(ations)0 3674 y Ft(Each)20
b(of)g(the)g(three)g(bitwise)g(operations)f(has)h(a)h(dif)n(ferent)d
(priority)h(le)n(v)o(el:)216 3817 y Fo(and_expr)98 b
Ft(::=)i Fo(shift_expr)48 b(|)h(and_expr)f("&")i(shift_expr)216
3916 y(xor_expr)98 b Ft(::=)i Fo(and_expr)48 b(|)i(xor_expr)e("\210")h
(and_expr)216 4016 y(or_expr)148 b Ft(::=)100 b Fo(xor_expr)48
b(|)i(or_expr)e("|")h(xor_expr)0 4158 y Ft(The)26 b Fo(&)h
Ft(operator)d(yields)i(the)h(bitwise)f(AND)h(of)f(its)i(ar)o(guments,)d
(which)h(must)g(be)g(plain)g(or)g(long)g(inte)o(gers.)42
b(The)26 b(ar)o(guments)f(are)0 4258 y(con)m(v)o(erted)18
b(to)i(a)h(common)d(type.)0 4405 y(The)25 b Fo(\210)g
Ft(operator)e(yields)i(the)g(bitwise)g(XOR)h(\(e)o(xclusi)n(v)o(e)d
(OR\))j(of)e(its)i(ar)o(guments,)e(which)g(must)h(be)g(plain)g(or)f
(long)h(inte)o(gers.)38 b(The)0 4504 y(ar)o(guments)18
b(are)i(con)m(v)o(erted)e(to)i(a)h(common)d(type.)0 4651
y(The)f Fo(|)g Ft(operator)f(yields)h(the)g(bitwise)g(\(inclusi)n(v)o
(e\))f(OR)i(of)f(its)h(ar)o(guments,)d(which)i(must)g(be)g(plain)g(or)f
(long)h(inte)o(gers.)23 b(The)17 b(ar)o(guments)0 4751
y(are)j(con)m(v)o(erted)e(to)i(a)h(common)d(type.)p 0
4822 1560 4 v 90 4877 a Ff(2)120 4901 y Fl(While)h Fb(abs\(x\045y\))39
b(<)h(abs\(y\))17 b Fl(is)i(true)g(mathematically)l(,)k(for)c(\003oats)
g(it)g(may)g(not)g(be)g(true)h(numerically)h(due)f(to)f(roundof)n(f.)27
b(F)o(or)18 b(e)o(xample,)j(and)e(assuming)0 4980 y(a)f(platform)i(on)e
(which)h(a)g(Python)g(\003oat)f(is)h(an)f(IEEE)f(754)h
(double-precision)k(number)m(,)d(in)g(order)g(that)g
Fb(-1e-100)39 b(\0451e100)17 b Fl(ha)o(v)o(e)i(the)g(same)f(sign)h(as)f
Fb(1e100)p Fl(,)f(the)0 5059 y(computed)k(result)g(is)f
Fb(-1e-100)39 b(+)g(1e100)p Fl(,)19 b(which)i(is)e(numerically)k(e)o
(xactly)f(equal)f(to)f Fb(1e100)p Fl(.)28 b(Function)22
b Fb(fmod\(\))c Fl(in)i(the)h Fb(math)d Fl(module)j(returns)g(a)e
(result)0 5138 y(whose)g(sign)g(matches)h(the)g(sign)f(of)g(the)g
(\002rst)g(ar)o(gument)h(instead,)h(and)e(so)f(returns)i
Fb(-1e-100)e Fl(in)h(this)g(case.)27 b(Which)19 b(approach)i(is)e(more)
g(appropriate)j(depends)e(on)0 5216 y(the)e(application.)90
5274 y Ff(3)120 5297 y Fl(If)f(x)g(is)h(v)o(ery)g(close)h(to)f(an)g(e)o
(xact)h(inte)o(ger)h(multiple)f(of)f(y)l(,)f(it')l(s)h(possible)h(for)f
Fb(floor\(x/y\))e Fl(to)h(be)h(one)g(lar)o(ger)h(than)g
Fb(\(x-x\045y\)/y)d Fl(due)i(to)g(rounding.)24 b(In)17
b(such)0 5376 y(cases,)g(Python)h(returns)g(the)g(latter)h(result,)f
(in)f(order)h(to)f(preserv)o(e)i(that)f Fb(divmod\(x,y\)[0])2259
5388 y(*)2338 5376 y(y)40 b(+)g(x)g(\045)f(y)17 b Fl(be)g(v)o(ery)h
(close)g(to)f Fb(x)p Fl(.)p 0 5549 3901 4 v 0 5649 a
Fp(48)2917 b(Chapter)23 b(5.)52 b(Expressions)p eop end
%%Page: 49 55
TeXDict begin 49 54 bop 0 88 a Fm(5.9)121 b(Compar)r(isons)0
321 y Ft(Unlik)o(e)29 b(C,)g(all)h(comparison)d(operations)g(in)j
(Python)d(ha)n(v)o(e)i(the)g(same)g(priority)-5 b(,)29
b(which)g(is)h(lo)n(wer)e(than)h(that)g(of)f(an)o(y)h(arithmetic,)0
421 y(shifting)18 b(or)h(bitwise)g(operation.)k(Also)c(unlik)o(e)f(C,)i
(e)o(xpressions)e(lik)o(e)h Fo(a)49 b(<)h(b)g(<)f(c)20
b Ft(ha)n(v)o(e)e(the)h(interpretation)e(that)i(is)h(con)m(v)o
(entional)0 520 y(in)g(mathematics:)216 646 y Fo(comparison)247
b Ft(::=)100 b Fo(or_expr)48 b(\()i(comp_operator)d(or_expr)i(\))2800
661 y(*)216 746 y(comp_operator)97 b Ft(::=)j Fo("<")49
b(|)h(">")f(|)g("==")g(|)h(">=")f(|)h("<=")f(|)g("<>")h(|)f("!=")1156
846 y(|)g("is")g(["not"])g(|)g(["not"])g("in")0 988 y
Ft(Comparisons)19 b(yield)h(boolean)e(v)n(alues:)25 b
Fo(True)20 b Ft(or)g Fo(False)p Ft(.)0 1135 y(Comparisons)g(can)g(be)h
(chained)e(arbitrarily)-5 b(,)19 b(e.g.,)h Fo(x)50 b(<)g(y)f(<=)h(z)21
b Ft(is)h(equi)n(v)n(alent)d(to)i Fo(x)49 b(<)h(y)f(and)h(y)f(<=)h(z)p
Ft(,)21 b(e)o(xcept)f(that)g Fo(y)i Ft(is)0 1234 y(e)n(v)n(aluated)d
(only)g(once)h(\(b)n(ut)f(in)i(both)e(cases)i Fo(z)g
Ft(is)g(not)f(e)n(v)n(aluated)e(at)j(all)g(when)e Fo(x)50
b(<)g(y)20 b Ft(is)h(found)e(to)h(be)g(f)o(alse\).)0
1381 y(F)o(ormally)-5 b(,)20 b(if)i Fq(a)p Ft(,)f Fq(b)p
Ft(,)h Fq(c)p Ft(,)g(.)12 b(.)g(.)g(,)23 b Fq(y)p Ft(,)f
Fq(z)g Ft(are)g(e)o(xpressions)e(and)h Fq(opa)p Ft(,)g
Fq(opb)p Ft(,)f(.)12 b(.)g(.)g(,)23 b Fq(opy)e Ft(are)h(comparison)d
(operators,)h(then)h Fq(a)h(opa)e(b)i(opb)f(c)h Ft(.)12
b(.)g(.)g Fq(y)0 1481 y(opy)20 b(z)h Ft(is)g(equi)n(v)n(alent)d(to)j
Fq(a)f(opa)f(b)h Fo(and)h Fq(b)f(opb)f(c)i Fo(and)f Ft(.)12
b(.)g(.)g Fq(y)21 b(opy)f(z)p Ft(,)h(e)o(xcept)e(that)h(each)g(e)o
(xpression)f(is)i(e)n(v)n(aluated)d(at)j(most)f(once.)0
1628 y(Note)f(that)g Fq(a)g(opa)f(b)h(opb)g(c)g Ft(doesn')o(t)e(imply)i
(an)o(y)f(kind)g(of)h(comparison)e(between)h Fq(a)h Ft(and)g
Fq(c)p Ft(,)g(so)h(that,)f(e.g.,)f Fo(x)50 b(<)f(y)h(>)g(z)19
b Ft(is)h(perfectly)0 1727 y(le)o(gal)f(\(though)g(perhaps)f(not)i
(pretty\).)0 1874 y(The)e(forms)g Fo(<>)h Ft(and)f Fo(!=)h
Ft(are)g(equi)n(v)n(alent;)e(for)h(consistenc)o(y)g(with)h(C,)g
Fo(!=)g Ft(is)g(preferred;)e(where)h Fo(!=)h Ft(is)h(mentioned)d(belo)n
(w)h Fo(<>)h Ft(is)g(also)0 1974 y(accepted.)24 b(The)c
Fo(<>)g Ft(spelling)g(is)h(considered)d(obsolescent.)0
2121 y(The)28 b(operators)f Fo(<)p Ft(,)k Fo(>)p Ft(,)f
Fo(==)p Ft(,)h Fo(>=)p Ft(,)f Fo(<=)p Ft(,)h(and)d Fo(!=)g
Ft(compare)f(the)i(v)n(alues)f(of)g(tw)o(o)g(objects.)50
b(The)28 b(objects)g(need)g(not)g(ha)n(v)o(e)g(the)g(same)0
2220 y(type.)c(If)19 b(both)f(are)h(numbers,)e(the)o(y)h(are)h(con)m(v)
o(erted)d(to)j(a)g(common)e(type.)24 b(Otherwise,)19
b(objects)g(of)f(dif)n(ferent)f(types)i Fq(always)g Ft(compare)0
2320 y(unequal,)24 b(and)g(are)g(ordered)f(consistently)h(b)n(ut)g
(arbitrarily)-5 b(.)37 b(Y)-9 b(ou)24 b(can)g(control)f(comparison)g
(beha)n(vior)g(of)h(objects)g(of)h(non-b)n(uiltin)0 2419
y(types)20 b(by)g(de\002ning)f(a)h Fo(__cmp__)g Ft(method)f(or)g(rich)h
(comparison)e(methods)i(lik)o(e)g Fo(__gt__)p Ft(,)f(described)g(in)i
(section)f(3.4.)0 2566 y(\(This)k(unusual)e(de\002nition)h(of)h
(comparison)e(w)o(as)i(used)g(to)g(simplify)f(the)h(de\002nition)f(of)g
(operations)g(lik)o(e)h(sorting)f(and)g(the)h Fo(in)g
Ft(and)0 2666 y Fo(not)49 b(in)21 b Ft(operators.)i(In)d(the)g(future,)
f(the)h(comparison)e(rules)i(for)g(objects)g(of)g(dif)n(ferent)e(types)
i(are)h(lik)o(ely)f(to)g(change.\))0 2813 y(Comparison)f(of)h(objects)g
(of)f(the)i(same)f(type)g(depends)f(on)g(the)i(type:)125
3043 y Fs(\017)41 b Ft(Numbers)19 b(are)h(compared)e(arithmetically)-5
b(.)125 3209 y Fs(\017)41 b Ft(Strings)16 b(are)h(compared)e(le)o
(xicographically)f(using)i(the)h(numeric)f(equi)n(v)n(alents)f(\(the)i
(result)g(of)g(the)g(b)n(uilt-in)f(function)f Fo(ord\(\))p
Ft(\))208 3308 y(of)k(their)h(characters.)k(Unicode)19
b(and)h(8-bit)g(strings)g(are)g(fully)g(interoperable)d(in)k(this)f
(beha)n(vior)-5 b(.)125 3474 y Fs(\017)41 b Ft(T)l(uples)21
b(and)h(lists)h(are)f(compared)e(le)o(xicographically)e(using)k
(comparison)e(of)h(corresponding)e(elements.)30 b(This)22
b(means)f(that)208 3574 y(to)g(compare)f(equal,)h(each)g(element)g
(must)h(compare)e(equal)h(and)g(the)g(tw)o(o)h(sequences)f(must)g(be)h
(of)f(the)g(same)h(type)f(and)g(ha)n(v)o(e)208 3674 y(the)f(same)g
(length.)208 3807 y(If)d(not)g(equal,)g(the)h(sequences)f(are)g
(ordered)f(the)i(same)f(as)i(their)e(\002rst)h(dif)n(fering)e
(elements.)24 b(F)o(or)17 b(e)o(xample,)f Fo(cmp\([1,2,x],)208
3906 y([1,2,y]\))k Ft(returns)h(the)g(same)h(as)g Fo(cmp\(x,y\))p
Ft(.)27 b(If)22 b(the)f(corresponding)d(element)j(does)g(not)g(e)o
(xist,)h(the)f(shorter)g(sequence)208 4006 y(is)g(ordered)d(\002rst)j
(\(for)e(e)o(xample,)g Fo([1,2])49 b(<)g([1,2,3])p Ft(\).)125
4172 y Fs(\017)41 b Ft(Mappings)22 b(\(dictionaries\))f(compare)h
(equal)h(if)h(and)e(only)h(if)h(their)f(sorted)g(\(k)o(e)o(y)-5
b(,)22 b(v)n(alue\))h(lists)h(compare)e(equal.)3496 4142
y Fg(4)3563 4172 y Ft(Outcomes)208 4271 y(other)d(than)h(equality)f
(are)h(resolv)o(ed)f(consistently)-5 b(,)19 b(b)n(ut)h(are)g(not)g
(otherwise)f(de\002ned.)2691 4241 y Fg(5)125 4437 y Fs(\017)41
b Ft(Most)26 b(other)f(objects)h(of)f(b)n(uiltin)h(types)g(compare)e
(unequal)g(unless)i(the)o(y)g(are)g(the)g(same)g(object;)i(the)e
(choice)f(whether)g(one)208 4537 y(object)19 b(is)j(considered)d
(smaller)h(or)g(lar)o(ger)f(than)h(another)f(one)h(is)i(made)d
(arbitrarily)g(b)n(ut)i(consistently)f(within)g(one)g(e)o(x)o(ecution)
208 4637 y(of)f(a)i(program.)0 4867 y(The)j(operators)e
Fo(in)i Ft(and)g Fo(not)49 b(in)24 b Ft(test)h(for)e(set)i(membership.)
34 b Fq(x)50 b Fo(in)g Fq(s)24 b Ft(e)n(v)n(aluates)g(to)g(true)f(if)i
Fq(x)f Ft(is)h(a)g(member)d(of)i(the)g(set)h Fq(s)p Ft(,)g(and)0
4966 y(f)o(alse)c(otherwise.)26 b Fq(x)50 b Fo(not)f(in)g
Fq(s)22 b Ft(returns)e(the)g(ne)o(gation)f(of)h Fq(x)50
b Fo(in)f Fq(s)p Ft(.)28 b(The)20 b(set)h(membership)e(test)j(has)e
(traditionally)f(been)h(bound)p 0 5037 1560 4 v 90 5093
a Ff(4)120 5116 y Fl(The)c(implementation)21 b(computes)d(this)g(ef)n
(\002ciently)l(,)h(without)g(constructing)h(lists)e(or)e(sorting.)90
5174 y Ff(5)120 5197 y Fl(Earlier)k(v)o(ersions)g(of)e(Python)i(used)f
(le)o(xicographic)k(comparison)d(of)f(the)h(sorted)f(\(k)o(e)o(y)l(,)h
(v)n(alue\))h(lists,)e(b)o(ut)g(this)h(w)o(as)f(v)o(ery)g(e)o(xpensi)n
(v)o(e)j(for)c(the)i(common)f(case)h(of)0 5276 y(comparing)d(for)f
(equality)l(.)22 b(An)16 b(e)n(v)o(en)h(earlier)h(v)o(ersion)f(of)e
(Python)i(compared)g(dictionaries)i(by)d(identity)i(only)l(,)e(b)o(ut)g
(this)g(caused)h(surprises)f(because)i(people)f(e)o(xpected)0
5355 y(to)g(be)h(able)g(to)f(test)h(a)f(dictionary)j(for)d(emptiness)h
(by)f(comparing)i(it)f(to)f Fb({})p Fl(.)p 0 5549 3901
4 v 0 5649 a Fp(5.9.)52 b(Compar)q(isons)3128 b(49)p
eop end
%%Page: 50 56
TeXDict begin 50 55 bop 0 83 a Ft(to)28 b(sequences;)j(an)d(object)g
(is)h(a)f(member)f(of)g(a)i(set)f(if)h(the)f(set)h(is)f(a)h(sequence)e
(and)g(contains)g(an)h(element)g(equal)f(to)h(that)g(object.)0
183 y(Ho)n(we)n(v)o(er)m(,)19 b(it)i(is)h(possible)e(for)g(an)h(object)
f(to)h(support)e(membership)g(tests)j(without)e(being)g(a)h(sequence.)k
(In)c(particular)m(,)e(dictionaries)0 282 y(support)g(membership)f
(testing)i(as)h(a)g(nicer)e(w)o(ay)i(of)f(spelling)f
Fq(k)o(e)n(y)49 b Fo(in)h Fq(dict)q Ft(;)21 b(other)e(mapping)f(types)i
(may)g(follo)n(w)g(suit.)0 429 y(F)o(or)g(the)g(list)h(and)f(tuple)g
(types,)g Fq(x)49 b Fo(in)h Fq(y)21 b Ft(is)g(true)e(if)i(and)f(only)f
(if)h(there)g(e)o(xists)h(an)f(inde)o(x)f Fq(i)i Ft(such)f(that)g
Fq(x)50 b Fo(==)f Fq(y)p Fo([)p Fq(i)p Fo(])21 b Ft(is)g(true.)0
576 y(F)o(or)d(the)h(Unicode)f(and)g(string)g(types,)h
Fq(x)49 b Fo(in)h Fq(y)19 b Ft(is)h(true)e(if)h(and)f(only)g(if)h
Fq(x)g Ft(is)h(a)f(substring)f(of)g Fq(y)p Ft(.)25 b(An)19
b(equi)n(v)n(alent)e(test)i(is)h Fo(y.find\(x\))0 676
y(!=)49 b(-1)p Ft(.)25 b(Note,)18 b Fq(x)h Ft(and)f Fq(y)h
Ft(need)e(not)h(be)g(the)g(same)h(type;)f(consequently)-5
b(,)16 b Fo(u'ab')49 b(in)g('abc')18 b Ft(will)h(return)e
Fo(True)p Ft(.)24 b(Empty)18 b(strings)0 775 y(are)h(al)o(w)o(ays)h
(considered)d(to)i(be)g(a)h(substring)e(of)h(an)o(y)f(other)g(string,)h
(so)h Fo("")49 b(in)g("abc")19 b Ft(will)h(return)e Fo(True)p
Ft(.)50 b(Changed)18 b(in)h(v)o(ersion)0 875 y(2.3:)h(Pre)n(viously)-5
b(,)18 b Fq(x)j Ft(w)o(as)g(required)d(to)i(be)h(a)f(string)g(of)g
(length)f Fo(1)p Ft(.)0 1022 y(F)o(or)39 b(user)n(-de\002ned)f(classes)
j(which)e(de\002ne)h(the)f Fo(__contains__\(\))f Ft(method,)43
b Fq(x)50 b Fo(in)f Fq(y)41 b Ft(is)f(true)g(if)g(and)f(only)g(if)h
Fq(y)p Fo(.__-)0 1121 y(contains__\()p Fq(x)p Fo(\))19
b Ft(is)i(true.)0 1268 y(F)o(or)h(user)n(-de\002ned)f(classes)i(which)f
(do)g(not)g(de\002ne)g Fo(__contains__\(\))f Ft(and)h(do)g(de\002ne)f
Fo(__getitem__\(\))p Ft(,)g Fq(x)50 b Fo(in)g Fq(y)23
b Ft(is)g(true)0 1368 y(if)h(and)g(only)f(if)h(there)f(is)i(a)g(non-ne)
o(gati)n(v)o(e)20 b(inte)o(ger)i(inde)o(x)h Fq(i)i Ft(such)e(that)h
Fq(x)50 b Fo(==)g Fq(y)p Fo([)p Fq(i)p Fo(])p Ft(,)24
b(and)g(all)g(lo)n(wer)g(inte)o(ger)e(indices)i(do)g(not)f(raise)0
1468 y Fo(IndexError)c Ft(e)o(xception.)k(\(If)d(an)o(y)f(other)g(e)o
(xception)g(is)i(raised,)f(it)g(is)i(as)f(if)f Fo(in)g
Ft(raised)g(that)h(e)o(xception\).)0 1614 y(The)f(operator)e
Fo(not)49 b(in)21 b Ft(is)g(de\002ned)e(to)i(ha)n(v)o(e)e(the)h(in)m(v)
o(erse)f(true)h(v)n(alue)g(of)g Fo(in)p Ft(.)0 1761 y(The)k(operators)f
Fo(is)i Ft(and)e Fo(is)50 b(not)24 b Ft(test)i(for)d(object)h
(identity:)33 b Fq(x)50 b Fo(is)g Fq(y)25 b Ft(is)g(true)f(if)h(and)f
(only)f(if)i Fq(x)g Ft(and)f Fq(y)h Ft(are)f(the)g(same)h(object.)37
b Fq(x)0 1861 y Fo(is)49 b(not)h Fq(y)20 b Ft(yields)g(the)h(in)m(v)o
(erse)e(truth)g(v)n(alue.)0 2188 y Fm(5.10)121 b(Boolean)35
b(oper)o(ations)0 2421 y Ft(Boolean)19 b(operations)g(ha)n(v)o(e)h(the)
g(lo)n(west)g(priority)f(of)h(all)h(Python)e(operations:)216
2564 y Fo(expression)695 b Ft(::=)100 b Fo(conditional_expression)46
b(|)j(lambda_form)216 2664 y(old_expression)495 b Ft(::=)100
b Fo(or_test)48 b(|)i(old_lambda_form)216 2764 y
(conditional_expression)95 b Ft(::=)100 b Fo(or_test)48
b(["if")h(or_test)g("else")g(expression])216 2863 y(or_test)845
b Ft(::=)100 b Fo(and_test)48 b(|)i(or_test)e("or")h(and_test)216
2963 y(and_test)795 b Ft(::=)100 b Fo(not_test)48 b(|)i(and_test)e
("and")h(not_test)216 3063 y(not_test)795 b Ft(::=)100
b Fo(comparison)48 b(|)i("not")e(not_test)0 3205 y Ft(In)25
b(the)g(conte)o(xt)g(of)g(Boolean)f(operations,)h(and)g(also)h(when)e
(e)o(xpressions)g(are)i(used)f(by)g(control)f(\003o)n(w)h(statements,)i
(the)e(follo)n(wing)0 3304 y(v)n(alues)c(are)g(interpreted)e(as)j(f)o
(alse:)28 b Fo(False)p Ft(,)21 b Fo(None)p Ft(,)g(numeric)f(zero)g(of)h
(all)h(types,)f(and)g(empty)f(strings)h(and)g(containers)f(\(including)
0 3404 y(strings,)g(tuples,)g(lists,)h(dictionaries,)e(sets)i(and)f
(frozensets\).)k(All)c(other)g(v)n(alues)g(are)g(interpreted)e(as)j
(true.)0 3551 y(The)f(operator)e Fo(not)i Ft(yields)h
Fo(True)f Ft(if)g(its)h(ar)o(gument)d(is)j(f)o(alse,)g
Fo(False)e Ft(otherwise.)0 3698 y(The)31 b(e)o(xpression)g
Fq(x)49 b Fo(if)h Fq(C)i Fo(else)d Fq(y)32 b Ft(\002rst)h(e)n(v)n
(aluates)e Fq(C)j Ft(\()p Fq(not)f(x)p Ft(\);)38 b(if)32
b Fq(C)i Ft(is)f(true,)h Fq(x)f Ft(is)f(e)n(v)n(aluated)f(and)g(its)i
(v)n(alue)e(is)h(returned;)0 3797 y(otherwise,)19 b Fq(y)i
Ft(is)g(e)n(v)n(aluated)e(and)g(its)j(v)n(alue)d(is)i(returned.)49
b(Ne)n(w)21 b(in)f(v)o(ersion)f(2.5.)0 3944 y(The)g(e)o(xpression)g
Fq(x)50 b Fo(and)f Fq(y)20 b Ft(\002rst)g(e)n(v)n(aluates)g
Fq(x)p Ft(;)g(if)g Fq(x)h Ft(is)f(f)o(alse,)h(its)f(v)n(alue)f(is)i
(returned;)d(otherwise,)h Fq(y)h Ft(is)h(e)n(v)n(aluated)d(and)i(the)f
(resulting)0 4044 y(v)n(alue)h(is)h(returned.)0 4191
y(The)i(e)o(xpression)f Fq(x)50 b Fo(or)f Fq(y)24 b Ft(\002rst)g(e)n(v)
n(aluates)f Fq(x)p Ft(;)j(if)d Fq(x)h Ft(is)h(true,)e(its)i(v)n(alue)d
(is)j(returned;)e(otherwise,)g Fq(y)h Ft(is)g(e)n(v)n(aluated)e(and)h
(the)g(resulting)0 4290 y(v)n(alue)d(is)h(returned.)0
4437 y(\(Note)j(that)g(neither)f Fo(and)h Ft(nor)f Fo(or)h
Ft(restrict)g(the)g(v)n(alue)g(and)f(type)h(the)o(y)f(return)g(to)h
Fo(False)g Ft(and)f Fo(True)p Ft(,)i(b)n(ut)f(rather)f(return)g(the)h
(last)0 4537 y(e)n(v)n(aluated)f(ar)o(gument.)35 b(This)25
b(is)g(sometimes)f(useful,)h(e.g.,)f(if)h Fo(s)g Ft(is)g(a)g(string)f
(that)g(should)f(be)i(replaced)e(by)h(a)h(def)o(ault)e(v)n(alue)h(if)h
(it)g(is)0 4636 y(empty)-5 b(,)19 b(the)i(e)o(xpression)e
Fo(s)50 b(or)f('foo')21 b Ft(yields)g(the)f(desired)g(v)n(alue.)27
b(Because)20 b Fo(not)h Ft(has)g(to)g(in)m(v)o(ent)f(a)h(v)n(alue)f(an)
o(yw)o(ay)-5 b(,)19 b(it)i(does)g(not)0 4736 y(bother)e(to)h(return)f
(a)i(v)n(alue)e(of)h(the)g(same)h(type)f(as)g(its)i(ar)o(gument,)17
b(so)k(e.g.,)e Fo(not)49 b('foo')20 b Ft(yields)g Fo(False)p
Ft(,)g(not)g Fo('')p Ft(.\))0 5063 y Fm(5.11)121 b(Lambdas)50
5277 y Fo(lambda_form)297 b Ft(::=)99 b Fo("lambda")49
b([parameter_list]:)96 b(expression)50 5376 y(old_lambda_form)h
Ft(::=)i Fo("lambda")49 b([parameter_list]:)96 b(old_expression)p
0 5549 3901 4 v 0 5649 a Fp(50)2917 b(Chapter)23 b(5.)52
b(Expressions)p eop end
%%Page: 51 57
TeXDict begin 51 56 bop 0 83 a Ft(Lambda)22 b(forms)g(\(lambda)f(e)o
(xpressions\))g(ha)n(v)o(e)i(the)g(same)g(syntactic)f(position)g(as)i
(e)o(xpressions.)32 b(The)o(y)22 b(are)h(a)g(shorthand)e(to)i(create)0
183 y(anon)o(ymous)30 b(functions;)37 b(the)32 b(e)o(xpression)f
Fo(lambda)49 b Fq(ar)m(guments)p Fo(:)98 b Fq(e)n(xpr)m(ession)32
b Ft(yields)h(a)f(function)f(object.)62 b(The)32 b(unnamed)0
282 y(object)20 b(beha)n(v)o(es)f(lik)o(e)h(a)h(function)d(object)i
(de\002ned)f(with)236 520 y Fi(def)45 b(name\(arguments\):)416
612 y(return)e(expression)0 898 y Ft(See)33 b(section)e(7.6)h(for)f
(the)i(syntax)e(of)h(parameter)e(lists.)62 b(Note)33
b(that)f(functions)e(created)i(with)g(lambda)f(forms)h(cannot)f
(contain)0 998 y(statements.)0 1325 y Fm(5.12)121 b(Expression)34
b(lists)50 1557 y Fo(expression_list)97 b Ft(::=)i Fo(expression)48
b(\()i(",")f(expression)f(\))2534 1572 y(*)2633 1557
y([","])0 1705 y Ft(An)22 b(e)o(xpression)e(list)j(containing)d(at)i
(least)h(one)e(comma)g(yields)g(a)h(tuple.)30 b(The)21
b(length)g(of)h(the)f(tuple)h(is)h(the)e(number)f(of)i(e)o(xpressions)0
1805 y(in)e(the)h(list.)26 b(The)19 b(e)o(xpressions)g(are)h(e)n(v)n
(aluated)f(from)g(left)i(to)f(right.)0 1952 y(The)26
b(trailing)f(comma)h(is)h(required)d(only)h(to)i(create)f(a)g(single)g
(tuple)g(\(a.k.a.)42 b(a)26 b Fq(singleton)p Ft(\);)i(it)f(is)g
(optional)e(in)h(all)h(other)e(cases.)44 b(A)0 2051 y(single)24
b(e)o(xpression)e(without)h(a)h(trailing)f(comma)g(doesn')o(t)f(create)
i(a)g(tuple,)g(b)n(ut)g(rather)f(yields)g(the)h(v)n(alue)f(of)h(that)g
(e)o(xpression.)34 b(\(T)-7 b(o)0 2151 y(create)20 b(an)g(empty)f
(tuple,)h(use)g(an)g(empty)g(pair)g(of)g(parentheses:)k
Fo(\(\))p Ft(.\))0 2478 y Fm(5.13)121 b(Ev)m(aluation)35
b(order)0 2711 y Ft(Python)27 b(e)n(v)n(aluates)g(e)o(xpressions)g
(from)g(left)h(to)g(right.)47 b(Notice)28 b(that)g(while)g(e)n(v)n
(aluating)e(an)i(assignment,)h(the)f(right-hand)d(side)k(is)0
2811 y(e)n(v)n(aluated)19 b(before)g(the)h(left-hand)e(side.)0
2958 y(In)i(the)g(follo)n(wing)f(lines,)h(e)o(xpressions)f(will)i(be)f
(e)n(v)n(aluated)f(in)h(the)g(arithmetic)g(order)f(of)g(their)h(suf)n
(\002x)o(es:)236 3104 y Fi(expr1,)44 b(expr2,)g(expr3,)g(expr4)236
3196 y(\(expr1,)g(expr2,)g(expr3,)g(expr4\))236 3287
y({expr1:)g(expr2,)g(expr3:)g(expr4})236 3378 y(expr1)g(+)h(expr2)864
3391 y(*)954 3378 y(\(expr3)e(-)i(expr4\))236 3470 y(func\(expr1,)e
(expr2,)1088 3483 y(*)1133 3470 y(expr3,)1447 3483 y(**)1537
3470 y(expr4\))236 3561 y(expr3,)h(expr4)g(=)h(expr1,)f(expr2)0
4010 y Fm(5.14)121 b(Summar)t(y)0 4243 y Ft(The)17 b(follo)n(wing)f
(table)i(summarizes)e(the)i(operator)e(precedences)g(in)h(Python,)g
(from)g(lo)n(west)g(precedence)f(\(least)i(binding\))d(to)j(highest)0
4342 y(precedence)d(\(most)i(binding\).)k(Operators)16
b(in)i(the)f(same)g(box)f(ha)n(v)o(e)g(the)h(same)g(precedence.)22
b(Unless)c(the)f(syntax)f(is)i(e)o(xplicitly)e(gi)n(v)o(en,)0
4442 y(operators)k(are)h(binary)-5 b(.)26 b(Operators)20
b(in)i(the)f(same)g(box)g(group)e(left)j(to)f(right)g(\(e)o(xcept)e
(for)i(comparisons,)e(including)h(tests,)i(which)f(all)0
4541 y(ha)n(v)o(e)26 b(the)g(same)h(precedence)d(and)i(chain)g(from)f
(left)i(to)g(right)f(\227)h(see)g(section)f(5.9)g(\226)g(and)g(e)o
(xponentiation,)f(which)h(groups)f(from)0 4641 y(right)20
b(to)g(left\).)p 0 5549 3901 4 v 0 5649 a Fp(5.12.)52
b(Expression)23 b(lists)2995 b(51)p eop end
%%Page: 52 58
TeXDict begin 52 57 bop 1154 70 a Fr(Operator)p 1792
100 4 100 v 355 w(Description)p 847 103 2207 4 v 1171
173 a Fo(lambda)p 1792 203 4 100 v 372 w Ft(Lambda)19
b(e)o(xpression)p 847 206 2207 4 v 1270 276 a Fo(or)p
1792 306 4 100 v 473 w Ft(Boolean)h(OR)p 847 309 2207
4 v 1245 379 a Fo(and)p 1792 408 4 100 v 448 w Ft(Boolean)g(AND)p
847 412 2207 4 v 1216 482 a Fo(not)h Fq(x)p 1792 511
4 100 v 419 w Ft(Boolean)f(NO)m(T)p 847 515 2207 4 v
1115 584 a Fo(in)p Ft(,)g Fo(not)g(in)p 1792 614 4 100
v 317 w Ft(Membership)f(tests)1100 684 y Fo(is)p Ft(,)h
Fo(is)50 b(not)p 1792 714 V 302 w Ft(Identity)19 b(tests)897
784 y Fo(<)p Ft(,)h Fo(<=)p Ft(,)g Fo(>)p Ft(,)g Fo(>=)p
Ft(,)h Fo(<>)p Ft(,)f Fo(!=)p Ft(,)g Fo(==)p 1792 814
V 99 w Ft(Comparisons)p 847 817 2207 4 v 1295 887 a Fo(|)p
1792 917 4 100 v 498 w Ft(Bitwise)i(OR)p 847 920 2207
4 v 1295 990 a Fo(\210)p 1792 1020 4 100 v 498 w Ft(Bitwise)g(XOR)p
847 1023 2207 4 v 1295 1093 a Fo(&)p 1792 1122 4 100
v 498 w Ft(Bitwise)g(AND)p 847 1126 2207 4 v 1200 1196
a Fo(<<)p Ft(,)e Fo(>>)p 1792 1225 4 100 v 402 w Ft(Shifts)p
847 1229 2207 4 v 1250 1298 a Fo(+)p Ft(,)g Fo(-)p 1792
1328 4 100 v 452 w Ft(Addition)f(and)h(subtraction)p
847 1332 2207 4 v 1204 1416 a Fo(*)1254 1401 y Ft(,)g
Fo(/)p Ft(,)g Fo(\045)p 1792 1431 4 100 v 407 w Ft(Multiplication,)f
(di)n(vision,)g(remainder)p 847 1435 2207 4 v 1212 1504
a Fo(+)p Fq(x)p Ft(,)i Fo(-)p Fq(x)p 1792 1534 4 100
v 415 w Ft(Positi)n(v)o(e,)f(ne)o(gati)n(v)o(e)1277 1604
y Fo(\230)p Fq(x)p 1792 1634 V 479 w Ft(Bitwise)i(not)p
847 1637 2207 4 v 1270 1722 a Fo(**)p 1792 1737 4 100
v 1843 1707 a Ft(Exponentiation)p 847 1740 2207 4 v 1134
1810 a Fq(x)p Fo(.)p Fq(attrib)n(ute)p 1792 1840 4 100
v 337 w Ft(Attrib)n(ute)e(reference)1163 1910 y Fq(x)p
Fo([)p Fq(inde)n(x)p Fo(])p 1792 1939 V 364 w Ft(Subscription)1048
2009 y Fq(x)p Fo([)p Fq(inde)n(x)p Fo(:)p Fq(inde)n(x)p
Fo(])p 1792 2039 V 250 w Ft(Slicing)1004 2109 y Fq(f)12
b Fo(\()p Fq(ar)m(guments)p Fo(...\))p 1792 2139 V 205
w Ft(Function)19 b(call)p 847 2142 2207 4 v 1004 2212
a Fo(\()p Fq(e)n(xpr)m(essions)p Fo(...\))p 1792 2242
4 100 v 206 w Ft(Binding)g(or)h(tuple)g(display)1004
2311 y Fo([)p Fq(e)n(xpr)m(essions)p Fo(...])p 1792 2341
V 206 w Ft(List)h(display)1013 2411 y Fo({)p Fq(k)o(e)n(y)p
Fo(:)p Fq(datum)p Fo(...})p 1792 2441 V 213 w Ft(Dictionary)e(display)
1004 2511 y Fo(`)p Fq(e)n(xpr)m(essions)p Fo(...`)p 1792
2540 V 206 w Ft(String)h(con)m(v)o(ersion)p 0 5549 3901
4 v 0 5649 a Fp(52)2917 b(Chapter)23 b(5.)52 b(Expressions)p
eop end
%%Page: 53 59
TeXDict begin 53 58 bop 0 83 3901 9 v 3503 230 a Fp(CHAPTER)3707
427 y Fn(SIX)p 0 515 V 2144 978 a Fz(Simple)56 b(statements)0
1465 y Ft(Simple)25 b(statements)h(are)g(comprised)e(within)h(a)h
(single)g(logical)f(line.)41 b(Se)n(v)o(eral)25 b(simple)g(statements)h
(may)f(occur)g(on)g(a)h(single)f(line)0 1565 y(separated)19
b(by)h(semicolons.)k(The)c(syntax)f(for)h(simple)g(statements)g(is:)216
1708 y Fo(simple_stmt)97 b Ft(::=)j Fo(expression_stmt)1056
1808 y(|)50 b(assert_stmt)1056 1907 y(|)g(assignment_stmt)1056
2007 y(|)g(augmented_assignment_stmt)1056 2106 y(|)g(pass_stmt)1056
2206 y(|)g(del_stmt)1056 2306 y(|)g(print_stmt)1056 2405
y(|)g(return_stmt)1056 2505 y(|)g(yield_stmt)1056 2605
y(|)g(raise_stmt)1056 2704 y(|)g(break_stmt)1056 2804
y(|)g(continue_stmt)1056 2903 y(|)g(import_stmt)1056
3003 y(|)g(global_stmt)1056 3103 y(|)g(exec_stmt)0 3405
y Fm(6.1)121 b(Expression)33 b(statements)0 3638 y Ft(Expression)19
b(statements)h(are)g(used)g(\(mostly)g(interacti)n(v)o(ely\))e(to)j
(compute)d(and)i(write)h(a)f(v)n(alue,)g(or)g(\(usually\))f(to)h(call)h
(a)g(procedure)c(\(a)0 3738 y(function)24 b(that)h(returns)g(no)g
(meaningful)e(result;)28 b(in)d(Python,)h(procedures)d(return)h(the)h
(v)n(alue)g Fo(None)p Ft(\).)40 b(Other)25 b(uses)h(of)f(e)o(xpression)
0 3837 y(statements)20 b(are)g(allo)n(wed)g(and)g(occasionally)e
(useful.)25 b(The)20 b(syntax)f(for)h(an)g(e)o(xpression)e(statement)i
(is:)216 3983 y Fo(expression_stmt)97 b Ft(::=)i Fo(expression_list)0
4131 y Ft(An)20 b(e)o(xpression)f(statement)h(e)n(v)n(aluates)f(the)i
(e)o(xpression)d(list)j(\(which)f(may)f(be)i(a)f(single)g(e)o
(xpression\).)0 4278 y(In)k(interacti)n(v)o(e)g(mode,)g(if)h(the)g(v)n
(alue)f(is)h(not)f Fo(None)p Ft(,)i(it)f(is)h(con)m(v)o(erted)c(to)i(a)
h(string)g(using)f(the)h(b)n(uilt-in)f Fo(repr\(\))g
Ft(function)e(and)j(the)0 4378 y(resulting)17 b(string)h(is)g(written)g
(to)g(standard)f(output)f(\(see)j(section)e(6.6\))g(on)h(a)g(line)g(by)
f(itself.)25 b(\(Expression)16 b(statements)i(yielding)f
Fo(None)0 4477 y Ft(are)j(not)g(written,)g(so)g(that)h(procedure)c
(calls)k(do)f(not)g(cause)g(an)o(y)f(output.\))0 4805
y Fm(6.2)121 b(Asser)5 b(t)33 b(statements)0 5037 y Ft(Assert)21
b(statements)f(are)g(a)h(con)m(v)o(enient)c(w)o(ay)k(to)f(insert)g(deb)
n(ugging)e(assertions)i(into)g(a)h(program:)216 5183
y Fo(assert_stmt)97 b Ft(::=)j Fo("assert")48 b(expression)g([",")h
(expression])0 5331 y Ft(The)20 b(simple)g(form,)f(`)p
Fo(assert)48 b(expression)p Ft(',)19 b(is)i(equi)n(v)n(alent)d(to)p
0 5549 3901 4 v 3808 5649 a Fp(53)p eop end
%%Page: 54 60
TeXDict begin 54 59 bop 236 174 a Fi(if)45 b(__debug__:)371
266 y(if)f(not)h(expression:)e(raise)h(AssertionError)0
552 y Ft(The)20 b(e)o(xtended)e(form,)h(`)p Fo(assert)48
b(expression1,)g(expression2)p Ft(',)18 b(is)j(equi)n(v)n(alent)e(to)
236 790 y Fi(if)45 b(__debug__:)371 882 y(if)f(not)h(expression1:)d
(raise)i(AssertionError,)f(expression2)0 1168 y Ft(These)15
b(equi)n(v)n(alences)f(assume)h(that)h Fo(__debug__)e
Ft(and)h Fo(AssertionError)e Ft(refer)i(to)g(the)h(b)n(uilt-in)f(v)n
(ariables)f(with)i(those)f(names.)0 1268 y(In)20 b(the)h(current)e
(implementation,)f(the)j(b)n(uilt-in)f(v)n(ariable)f
Fo(__debug__)g Ft(is)j Fo(True)e Ft(under)f(normal)h(circumstances,)f
Fo(False)h Ft(when)0 1367 y(optimization)26 b(is)j(requested)d
(\(command)f(line)j(option)f(-O\).)g(The)g(current)g(code)g(generator)f
(emits)i(no)f(code)g(for)g(an)h(assert)g(state-)0 1467
y(ment)c(when)g(optimization)f(is)i(requested)e(at)i(compile)f(time.)38
b(Note)24 b(that)h(it)g(is)h(unnecessary)c(to)j(include)f(the)g(source)
g(code)g(for)g(the)0 1567 y(e)o(xpression)19 b(that)h(f)o(ailed)g(in)g
(the)g(error)f(message;)i(it)f(will)h(be)g(displayed)e(as)h(part)g(of)g
(the)g(stack)h(trace.)0 1714 y(Assignments)f(to)g Fo(__debug__)f
Ft(are)h(ille)o(gal.)25 b(The)20 b(v)n(alue)f(for)h(the)g(b)n(uilt-in)f
(v)n(ariable)g(is)j(determined)c(when)h(the)i(interpreter)d(starts.)0
2041 y Fm(6.3)121 b(Assignment)33 b(statements)0 2274
y Ft(Assignment)19 b(statements)i(are)f(used)g(to)g(\(re\)bind)e(names)
i(to)g(v)n(alues)g(and)g(to)g(modify)f(attrib)n(utes)h(or)g(items)h(of)
e(mutable)h(objects:)216 2417 y Fo(assignment_stmt)97
b Ft(::=)i Fo(\(target_list)48 b("="\)+)h(\(expression_list)e(|)i
(yield_expression\))216 2517 y(target_list)297 b Ft(::=)99
b Fo(target)49 b(\(",")g(target\))2203 2532 y(*)2301
2517 y([","])216 2616 y(target)547 b Ft(::=)99 b Fo(identifier)1255
2716 y(|)50 b("\(")f(target_list)f("\)")1255 2816 y(|)i("[")f
(target_list)f("]")1255 2915 y(|)i(attributeref)1255
3015 y(|)g(subscription)1255 3114 y(|)g(slicing)0 3300
y Ft(\(See)20 b(section)g(5.3)g(for)f(the)i(syntax)e(de\002nitions)g
(for)h(the)g(last)h(three)f(symbols.\))0 3446 y(An)27
b(assignment)g(statement)g(e)n(v)n(aluates)g(the)g(e)o(xpression)f
(list)j(\(remember)c(that)i(this)h(can)g(be)f(a)h(single)f(e)o
(xpression)f(or)h(a)h(comma-)0 3546 y(separated)21 b(list,)i(the)f
(latter)g(yielding)e(a)i(tuple\))f(and)h(assigns)g(the)g(single)f
(resulting)g(object)h(to)g(each)f(of)h(the)f(tar)o(get)g(lists,)j(from)
c(left)i(to)0 3646 y(right.)0 3793 y(Assignment)e(is)h(de\002ned)f
(recursi)n(v)o(ely)e(depending)g(on)i(the)h(form)e(of)i(the)f(tar)o
(get)g(\(list\).)26 b(When)20 b(a)h(tar)o(get)f(is)h(part)f(of)h(a)g
(mutable)e(object)0 3892 y(\(an)g(attrib)n(ute)f(reference,)g
(subscription)f(or)i(slicing\),)g(the)g(mutable)f(object)h(must)g
(ultimately)f(perform)f(the)i(assignment)g(and)f(decide)0
3992 y(about)k(its)h(v)n(alidity)-5 b(,)22 b(and)g(may)g(raise)h(an)f
(e)o(xception)f(if)h(the)h(assignment)f(is)h(unacceptable.)30
b(The)22 b(rules)h(observ)o(ed)d(by)i(v)n(arious)g(types)0
4091 y(and)e(the)g(e)o(xceptions)e(raised)i(are)h(gi)n(v)o(en)d(with)j
(the)f(de\002nition)f(of)h(the)g(object)g(types)g(\(see)g(section)g
(3.2\).)0 4238 y(Assignment)f(of)h(an)g(object)g(to)g(a)h(tar)o(get)e
(list)j(is)f(recursi)n(v)o(ely)d(de\002ned)h(as)i(follo)n(ws.)125
4468 y Fs(\017)41 b Ft(If)20 b(the)g(tar)o(get)f(list)i(is)h(a)e
(single)g(tar)o(get:)25 b(The)19 b(object)h(is)h(assigned)f(to)g(that)h
(tar)o(get.)125 4634 y Fs(\017)41 b Ft(If)23 b(the)h(tar)o(get)f(list)j
(is)f(a)f(comma-separated)d(list)k(of)f(tar)o(gets:)32
b(The)24 b(object)f(must)h(be)g(a)h(sequence)d(with)j(the)f(same)g
(number)e(of)208 4734 y(items)j(as)h(there)e(are)h(tar)o(gets)g(in)g
(the)g(tar)o(get)f(list,)j(and)e(the)g(items)g(are)g(assigned,)h(from)e
(left)h(to)g(right,)h(to)f(the)g(corresponding)208 4833
y(tar)o(gets.)j(\(This)21 b(rule)g(is)h(relax)o(ed)e(as)j(of)e(Python)f
(1.5;)h(in)h(earlier)f(v)o(ersions,)g(the)g(object)g(had)g(to)g(be)h(a)
g(tuple.)28 b(Since)21 b(strings)h(are)208 4933 y(sequences,)d(an)h
(assignment)f(lik)o(e)i(`)p Fo(a,)49 b(b)g(=)h("xy")p
Ft(')20 b(is)h(no)n(w)e(le)o(gal)h(as)h(long)e(as)i(the)f(string)g(has)
h(the)f(right)f(length.\))0 5163 y(Assignment)g(of)h(an)g(object)g(to)g
(a)h(single)f(tar)o(get)f(is)j(recursi)n(v)o(ely)c(de\002ned)h(as)i
(follo)n(ws.)125 5393 y Fs(\017)41 b Ft(If)20 b(the)g(tar)o(get)f(is)i
(an)f(identi\002er)g(\(name\):)p 0 5549 3901 4 v 0 5649
a Fp(54)2663 b(Chapter)23 b(6.)52 b(Simple)25 b(statements)p
eop end
%%Page: 55 61
TeXDict begin 55 60 bop 307 83 a Fr(\226)41 b Ft(If)26
b(the)g(name)f(does)g(not)g(occur)g(in)h(a)g Fo(global)f
Ft(statement)h(in)g(the)g(current)e(code)h(block:)35
b(the)26 b(name)f(is)i(bound)d(to)i(the)390 183 y(object)20
b(in)g(the)g(current)f(local)h(namespace.)307 312 y Fr(\226)41
b Ft(Otherwise:)25 b(the)20 b(name)g(is)h(bound)d(to)j(the)f(object)g
(in)g(the)g(current)f(global)g(namespace.)208 490 y(The)27
b(name)h(is)h(rebound)d(if)j(it)f(w)o(as)i(already)d(bound.)47
b(This)28 b(may)g(cause)g(the)g(reference)f(count)g(for)h(the)g(object)
g(pre)n(viously)208 590 y(bound)d(to)j(the)g(name)f(to)h(reach)f(zero,)
i(causing)e(the)h(object)f(to)h(be)f(deallocated)g(and)g(its)i
(destructor)d(\(if)i(it)g(has)g(one\))f(to)h(be)208 689
y(called.)125 852 y Fs(\017)41 b Ft(If)18 b(the)h(tar)o(get)f(is)i(a)f
(tar)o(get)f(list)i(enclosed)e(in)h(parentheses)f(or)g(in)h(square)f
(brack)o(ets:)24 b(The)19 b(object)f(must)h(be)g(a)g(sequence)f(with)h
(the)208 952 y(same)k(number)e(of)i(items)g(as)h(there)e(are)h(tar)o
(gets)g(in)g(the)g(tar)o(get)f(list,)i(and)f(its)h(items)f(are)g
(assigned,)g(from)f(left)h(to)h(right,)e(to)i(the)208
1051 y(corresponding)16 b(tar)o(gets.)125 1214 y Fs(\017)41
b Ft(If)24 b(the)h(tar)o(get)f(is)i(an)e(attrib)n(ute)h(reference:)33
b(The)24 b(primary)f(e)o(xpression)g(in)i(the)g(reference)e(is)j(e)n(v)
n(aluated.)37 b(It)25 b(should)f(yield)h(an)208 1314
y(object)15 b(with)i(assignable)f(attrib)n(utes;)h(if)g(this)g(is)g
(not)g(the)f(case,)h Fo(TypeError)f Ft(is)h(raised.)23
b(That)17 b(object)e(is)j(then)e(ask)o(ed)g(to)g(assign)208
1413 y(the)j(assigned)h(object)f(to)h(the)g(gi)n(v)o(en)f(attrib)n
(ute;)g(if)i(it)f(cannot)f(perform)f(the)i(assignment,)f(it)h(raises)h
(an)f(e)o(xception)e(\(usually)h(b)n(ut)208 1513 y(not)g(necessarily)h
Fo(AttributeError)p Ft(\).)125 1676 y Fs(\017)41 b Ft(If)31
b(the)g(tar)o(get)g(is)h(a)g(subscription:)47 b(The)31
b(primary)f(e)o(xpression)g(in)h(the)h(reference)e(is)i(e)n(v)n
(aluated.)58 b(It)31 b(should)g(yield)g(either)208 1776
y(a)h(mutable)f(sequence)f(object)h(\(such)h(as)g(a)g(list\))h(or)e(a)i
(mapping)d(object)h(\(such)g(as)h(a)h(dictionary\).)57
b(Ne)o(xt,)34 b(the)e(subscript)208 1875 y(e)o(xpression)18
b(is)j(e)n(v)n(aluated.)208 2006 y(If)28 b(the)h(primary)e(is)i(a)g
(mutable)f(sequence)f(object)h(\(such)g(as)i(a)f(list\),)i(the)d
(subscript)g(must)h(yield)f(a)h(plain)f(inte)o(ger)-5
b(.)50 b(If)28 b(it)i(is)208 2106 y(ne)o(gati)n(v)o(e,)23
b(the)i(sequence')-5 b(s)23 b(length)h(is)i(added)d(to)i(it.)39
b(The)24 b(resulting)g(v)n(alue)g(must)h(be)f(a)h(nonne)o(gati)n(v)o(e)
c(inte)o(ger)j(less)h(than)g(the)208 2206 y(sequence')-5
b(s)16 b(length,)h(and)g(the)g(sequence)f(is)j(ask)o(ed)e(to)g(assign)h
(the)f(assigned)g(object)g(to)g(its)i(item)e(with)h(that)f(inde)o(x.)23
b(If)17 b(the)h(inde)o(x)208 2305 y(is)i(out)f(of)g(range,)f
Fo(IndexError)h Ft(is)h(raised)f(\(assignment)f(to)i(a)g(subscripted)e
(sequence)g(cannot)h(add)g(ne)n(w)g(items)h(to)f(a)h(list\).)208
2436 y(If)25 b(the)h(primary)e(is)j(a)f(mapping)e(object)h(\(such)g(as)
i(a)f(dictionary\),)f(the)h(subscript)f(must)h(ha)n(v)o(e)f(a)h(type)f
(compatible)g(with)h(the)208 2536 y(mapping')-5 b(s)21
b(k)o(e)o(y)h(type,)h(and)f(the)h(mapping)e(is)i(then)g(ask)o(ed)f(to)h
(create)g(a)g(k)o(e)o(y/datum)d(pair)j(which)f(maps)h(the)g(subscript)f
(to)h(the)208 2636 y(assigned)k(object.)49 b(This)28
b(can)g(either)g(replace)f(an)h(e)o(xisting)g(k)o(e)o(y/v)n(alue)e
(pair)i(with)h(the)f(same)g(k)o(e)o(y)g(v)n(alue,)h(or)f(insert)g(a)h
(ne)n(w)208 2735 y(k)o(e)o(y/v)n(alue)18 b(pair)i(\(if)g(no)g(k)o(e)o
(y)f(with)i(the)f(same)g(v)n(alue)g(e)o(xisted\).)125
2898 y Fs(\017)41 b Ft(If)17 b(the)g(tar)o(get)g(is)h(a)g(slicing:)24
b(The)17 b(primary)e(e)o(xpression)h(in)i(the)f(reference)f(is)i(e)n(v)
n(aluated.)23 b(It)17 b(should)g(yield)g(a)g(mutable)g(sequence)208
2998 y(object)22 b(\(such)h(as)h(a)f(list\).)35 b(The)23
b(assigned)g(object)f(should)g(be)i(a)f(sequence)f(object)h(of)g(the)g
(same)g(type.)34 b(Ne)o(xt,)23 b(the)g(lo)n(wer)g(and)208
3097 y(upper)i(bound)h(e)o(xpressions)g(are)h(e)n(v)n(aluated,)g(insof)
o(ar)g(the)o(y)f(are)h(present;)k(def)o(aults)26 b(are)i(zero)e(and)h
(the)g(sequence')-5 b(s)27 b(length.)208 3197 y(The)20
b(bounds)f(should)h(e)n(v)n(aluate)g(to)g(\(small\))h(inte)o(gers.)26
b(If)20 b(either)h(bound)d(is)k(ne)o(gati)n(v)o(e,)c(the)j(sequence')-5
b(s)20 b(length)g(is)i(added)d(to)i(it.)208 3297 y(The)e(resulting)h
(bounds)e(are)i(clipped)g(to)g(lie)h(between)e(zero)h(and)f(the)i
(sequence')-5 b(s)19 b(length,)g(inclusi)n(v)o(e.)24
b(Finally)-5 b(,)20 b(the)g(sequence)208 3396 y(object)27
b(is)i(ask)o(ed)f(to)h(replace)e(the)h(slice)h(with)g(the)f(items)h(of)
f(the)g(assigned)g(sequence.)48 b(The)27 b(length)h(of)g(the)g(slice)h
(may)f(be)208 3496 y(dif)n(ferent)18 b(from)g(the)i(length)f(of)h(the)g
(assigned)f(sequence,)f(thus)i(changing)e(the)i(length)e(of)i(the)g
(tar)o(get)f(sequence,)f(if)i(the)g(object)208 3596 y(allo)n(ws)g(it.)0
3817 y(\(In)h(the)h(current)f(implementation,)f(the)i(syntax)f(for)g
(tar)o(gets)g(is)i(tak)o(en)f(to)g(be)g(the)g(same)g(as)g(for)g(e)o
(xpressions,)e(and)i(in)m(v)n(alid)e(syntax)i(is)0 3917
y(rejected)e(during)e(the)i(code)g(generation)e(phase,)h(causing)h
(less)h(detailed)f(error)f(messages.\))0 4064 y(W)-10
b(ARNING:)19 b(Although)e(the)h(de\002nition)f(of)h(assignment)g
(implies)g(that)g(o)o(v)o(erlaps)f(between)h(the)g(left-hand)e(side)j
(and)f(the)g(right-hand)0 4163 y(side)31 b(are)f(`safe')f(\(for)h(e)o
(xample)f(`)p Fo(a,)49 b(b)g(=)h(b,)f(a)p Ft(')31 b(sw)o(aps)f(tw)o(o)h
(v)n(ariables\),)g(o)o(v)o(erlaps)e Fq(within)h Ft(the)h(collection)e
(of)h(assigned-to)0 4263 y(v)n(ariables)19 b(are)i(not)e(safe!)25
b(F)o(or)20 b(instance,)g(the)g(follo)n(wing)f(program)f(prints)h(`)p
Fo([0,)49 b(2])p Ft(':)236 4501 y Fi(x)c(=)g([0,)f(1])236
4593 y(i)h(=)g(0)236 4684 y(i,)g(x[i])f(=)h(1,)f(2)236
4775 y(print)g(x)0 5197 y Fk(6.3.1)100 b(A)m(ugmented)30
b(assignment)f(statements)0 5400 y Ft(Augmented)17 b(assignment)h(is)i
(the)f(combination,)d(in)k(a)f(single)g(statement,)f(of)h(a)g(binary)f
(operation)f(and)i(an)f(assignment)g(statement:)p 0 5549
3901 4 v 0 5649 a Fp(6.3.)52 b(Assignment)24 b(statements)2755
b(55)p eop end
%%Page: 56 62
TeXDict begin 56 61 bop 216 70 a Fo(augmented_assignment_stmt)95
b Ft(::=)k Fo(target)49 b(augop)g(\(expression_list)e(|)i
(yield_expression\))216 169 y(augop)1095 b Ft(::=)99
b Fo("+=")49 b(|)h("-=")f(|)h(")2501 184 y(*)2551 169
y(=")f(|)g("/=")h(|)f("\045=")g(|)h(")3547 184 y(**)3647
169 y(=")1753 269 y(|)g(">>=")f(|)h("<<=")e(|)i("&=")f(|)h("\210=")f(|)
g("|=")0 454 y Ft(\(See)20 b(section)g(5.3)g(for)f(the)i(syntax)e
(de\002nitions)g(for)h(the)g(last)h(three)f(symbols.\))0
601 y(An)f(augmented)e(assignment)i(e)n(v)n(aluates)f(the)h(tar)o(get)g
(\(which,)f(unlik)o(e)h(normal)e(assignment)i(statements,)g(cannot)f
(be)h(an)g(unpacking\))0 701 y(and)28 b(the)g(e)o(xpression)e(list,)32
b(performs)26 b(the)i(binary)f(operation)f(speci\002c)j(to)f(the)g
(type)g(of)g(assignment)f(on)h(the)g(tw)o(o)h(operands,)f(and)0
800 y(assigns)21 b(the)f(result)g(to)g(the)h(original)e(tar)o(get.)24
b(The)c(tar)o(get)f(is)i(only)e(e)n(v)n(aluated)g(once.)0
947 y(An)28 b(augmented)f(assignment)g(e)o(xpression)g(lik)o(e)i
Fo(x)49 b(+=)h(1)28 b Ft(can)h(be)f(re)n(written)g(as)h
Fo(x)49 b(=)h(x)g(+)f(1)29 b Ft(to)f(achie)n(v)o(e)g(a)g(similar)m(,)j
(b)n(ut)d(not)0 1047 y(e)o(xactly)21 b(equal)f(ef)n(fect.)28
b(In)22 b(the)f(augmented)e(v)o(ersion,)i Fo(x)g Ft(is)i(only)d(e)n(v)n
(aluated)g(once.)28 b(Also,)22 b(when)f(possible,)g(the)h(actual)f
(operation)f(is)0 1146 y(performed)i Fq(in-place)p Ft(,)h(meaning)g
(that)h(rather)g(than)f(creating)g(a)i(ne)n(w)f(object)g(and)f
(assigning)h(that)g(to)h(the)f(tar)o(get,)g(the)g(old)g(object)g(is)0
1246 y(modi\002ed)19 b(instead.)0 1393 y(W)m(ith)f(the)g(e)o(xception)e
(of)h(assigning)g(to)h(tuples)f(and)h(multiple)f(tar)o(gets)g(in)h(a)g
(single)f(statement,)h(the)g(assignment)f(done)f(by)i(augmented)0
1492 y(assignment)d(statements)h(is)h(handled)d(the)i(same)g(w)o(ay)f
(as)i(normal)e(assignments.)22 b(Similarly)-5 b(,)16
b(with)g(the)g(e)o(xception)e(of)h(the)h(possible)g Fq(in-)0
1592 y(place)i Ft(beha)n(vior)m(,)f(the)i(binary)e(operation)g
(performed)f(by)i(augmented)f(assignment)g(is)j(the)f(same)g(as)g(the)g
(normal)e(binary)g(operations.)0 1739 y(F)o(or)23 b(tar)o(gets)f(which)
h(are)f(attrib)n(ute)h(references,)f(the)h(initial)h(v)n(alue)e(is)i
(retrie)n(v)o(ed)d(with)i(a)h Fo(getattr\(\))e Ft(and)g(the)h(result)g
(is)h(assigned)0 1839 y(with)f(a)f Fo(setattr\(\))p Ft(.)31
b(Notice)22 b(that)h(the)f(tw)o(o)h(methods)e(do)i(not)f(necessarily)f
(refer)h(to)h(the)f(same)h(v)n(ariable.)30 b(When)23
b Fo(getattr\(\))0 1938 y Ft(refers)d(to)g(a)h(class)g(v)n(ariable,)e
Fo(setattr\(\))g Ft(still)i(writes)g(to)f(an)g(instance)g(v)n(ariable.)
k(F)o(or)c(e)o(xample:)236 2176 y Fi(class)44 b(A:)416
2268 y(x)g(=)h(3)179 b(#)45 b(class)f(variable)236 2359
y(a)h(=)g(A\(\))236 2450 y(a.x)g(+=)f(1)224 b(#)45 b(writes)f(a.x)g(as)
g(4)h(leaving)f(A.x)g(as)g(3)0 2897 y Fm(6.4)121 b(The)34
b Fa(pass)e Fm(statement)50 3129 y Fo(pass_stmt)98 b
Ft(::=)h Fo("pass")0 3277 y(pass)25 b Ft(is)g(a)h(null)e(operation)f
(\227)j(when)e(it)h(is)h(e)o(x)o(ecuted,)e(nothing)f(happens.)38
b(It)25 b(is)h(useful)e(as)i(a)f(placeholder)e(when)h(a)h(statement)g
(is)0 3377 y(required)18 b(syntactically)-5 b(,)19 b(b)n(ut)h(no)g
(code)g(needs)f(to)i(be)f(e)o(x)o(ecuted,)e(for)i(e)o(xample:)236
3615 y Fi(def)45 b(f\(arg\):)e(pass)179 b(#)45 b(a)f(function)g(that)g
(does)g(nothing)g(\(yet\))236 3798 y(class)g(C:)h(pass)313
b(#)45 b(a)f(class)g(with)g(no)h(methods)e(\(yet\))0
4245 y Fm(6.5)121 b(The)34 b Fa(del)e Fm(statement)50
4476 y Fo(del_stmt)98 b Ft(::=)i Fo("del")48 b(target_list)0
4624 y Ft(Deletion)19 b(is)i(recursi)n(v)o(ely)e(de\002ned)f(v)o(ery)h
(similar)i(to)f(the)g(w)o(ay)g(assignment)f(is)i(de\002ned.)j(Rather)c
(that)g(spelling)f(it)i(out)e(in)i(full)e(details,)0
4724 y(here)h(are)g(some)g(hints.)0 4871 y(Deletion)g(of)g(a)g(tar)o
(get)g(list)h(recursi)n(v)o(ely)d(deletes)i(each)g(tar)o(get,)f(from)g
(left)i(to)f(right.)0 5018 y(Deletion)i(of)g(a)h(name)f(remo)o(v)o(es)e
(the)j(binding)e(of)h(that)g(name)g(from)f(the)i(local)f(or)g(global)g
(namespace,)f(depending)f(on)i(whether)g(the)0 5117 y(name)g(occurs)g
(in)g(a)h Fo(global)f Ft(statement)g(in)h(the)f(same)h(code)f(block.)30
b(If)23 b(the)f(name)g(is)h(unbound,)d(a)j Fo(NameError)e
Ft(e)o(xception)g(will)0 5217 y(be)f(raised.)0 5364 y(It)g(is)i(ille)o
(gal)d(to)i(delete)f(a)g(name)g(from)f(the)h(local)g(namespace)f(if)i
(it)g(occurs)e(as)i(a)g(free)e(v)n(ariable)h(in)g(a)g(nested)g(block.)p
0 5549 3901 4 v 0 5649 a Fp(56)2663 b(Chapter)23 b(6.)52
b(Simple)25 b(statements)p eop end
%%Page: 57 63
TeXDict begin 57 62 bop 0 83 a Ft(Deletion)16 b(of)f(attrib)n(ute)h
(references,)f(subscriptions)g(and)h(slicings)g(is)h(passed)f(to)g(the)
h(primary)d(object)i(in)m(v)n(olv)o(ed;)f(deletion)g(of)h(a)h(slicing)0
183 y(is)27 b(in)g(general)e(equi)n(v)n(alent)g(to)h(assignment)g(of)g
(an)g(empty)g(slice)h(of)f(the)g(right)g(type)g(\(b)n(ut)g(e)n(v)o(en)f
(this)i(is)h(determined)c(by)i(the)g(sliced)0 282 y(object\).)0
610 y Fm(6.6)121 b(The)34 b Fa(print)e Fm(statement)50
840 y Fo(print_stmt)98 b Ft(::=)h Fo("print")49 b(\([expression)e
(\(",")i(expression\))2685 855 y(*)2783 840 y([","])840
939 y(|)h(">>")f(expression)f([\(",")h(expression\)+)e([","]\))0
1081 y(print)23 b Ft(e)n(v)n(aluates)g(each)g(e)o(xpression)f(in)i
(turn)f(and)g(writes)h(the)g(resulting)f(object)g(to)g(standard)g
(output)f(\(see)i(belo)n(w\).)34 b(If)24 b(an)f(object)0
1181 y(is)h(not)f(a)h(string,)g(it)g(is)g(\002rst)g(con)m(v)o(erted)d
(to)j(a)f(string)g(using)g(the)h(rules)f(for)g(string)g(con)m(v)o
(ersions.)32 b(The)23 b(\(resulting)f(or)h(original\))f(string)0
1281 y(is)28 b(then)e(written.)45 b(A)27 b(space)g(is)h(written)f
(before)e(each)i(object)f(is)i(\(con)m(v)o(erted)c(and\))i(written,)i
(unless)f(the)g(output)e(system)i(belie)n(v)o(es)0 1380
y(it)f(is)f(positioned)f(at)h(the)g(be)o(ginning)d(of)i(a)i(line.)39
b(This)25 b(is)g(the)g(case)g(\(1\))g(when)f(no)g(characters)g(ha)n(v)o
(e)g(yet)h(been)f(written)h(to)g(standard)0 1480 y(output,)20
b(\(2\))g(when)h(the)g(last)h(character)e(written)h(to)g(standard)f
(output)g(is)i(`)p Fo(\\n)p Ft(',)f(or)f(\(3\))h(when)f(the)h(last)h
(write)g(operation)d(on)i(standard)0 1580 y(output)d(w)o(as)h(not)g(a)g
Fo(print)f Ft(statement.)24 b(\(In)19 b(some)f(cases)i(it)f(may)f(be)h
(functional)e(to)i(write)g(an)g(empty)f(string)g(to)h(standard)f
(output)f(for)0 1679 y(this)22 b(reason.\))29 b Fr(Note:)e
Ft(Objects)22 b(which)g(act)g(lik)o(e)g(\002le)g(objects)g(b)n(ut)g
(which)f(are)h(not)f(the)h(b)n(uilt-in)f(\002le)h(objects)g(often)f(do)
g(not)h(properly)0 1779 y(emulate)e(this)g(aspect)h(of)e(the)i(\002le)g
(object')-5 b(s)20 b(beha)n(vior)m(,)e(so)i(it)h(is)g(best)g(not)f(to)g
(rely)g(on)g(this.)0 1926 y(A)i(`)p Fo(\\n)p Ft(')g(character)e(is)j
(written)f(at)g(the)g(end,)g(unless)g(the)g Fo(print)f
Ft(statement)h(ends)g(with)g(a)g(comma.)29 b(This)22
b(is)h(the)f(only)f(action)g(if)i(the)0 2025 y(statement)d(contains)f
(just)i(the)f(k)o(e)o(yw)o(ord)f Fo(print)p Ft(.)0 2172
y(Standard)g(output)g(is)i(de\002ned)f(as)h(the)f(\002le)h(object)f
(named)f Fo(stdout)g Ft(in)i(the)f(b)n(uilt-in)g(module)f
Fo(sys)p Ft(.)25 b(If)20 b(no)g(such)g(object)g(e)o(xists,)g(or)g(if)0
2272 y(it)h(does)f(not)g(ha)n(v)o(e)f(a)i Fo(write\(\))e
Ft(method,)g(a)i Fo(RuntimeError)d Ft(e)o(xception)g(is)j(raised.)0
2419 y Fo(print)i Ft(also)g(has)g(an)g(e)o(xtended)e(form,)i(de\002ned)
e(by)i(the)g(second)f(portion)g(of)g(the)h(syntax)g(described)e(abo)o
(v)o(e.)32 b(This)23 b(form)f(is)i(some-)0 2518 y(times)k(referred)d
(to)i(as)h(\223)p Fo(print)e Ft(che)n(vron.)-6 b(\224)44
b(In)27 b(this)g(form,)h(the)f(\002rst)g(e)o(xpression)f(after)h(the)g
Fo(>>)g Ft(must)g(e)n(v)n(aluate)f(to)h(a)h(\223\002le-lik)o(e\224)0
2618 y(object,)e(speci\002cally)g(an)g(object)f(that)h(has)g(a)g
Fo(write\(\))f Ft(method)f(as)j(described)d(abo)o(v)o(e.)40
b(W)m(ith)26 b(this)g(e)o(xtended)e(form,)i(the)g(subse-)0
2718 y(quent)20 b(e)o(xpressions)g(are)i(printed)e(to)h(this)h(\002le)g
(object.)27 b(If)22 b(the)f(\002rst)h(e)o(xpression)e(e)n(v)n(aluates)g
(to)i Fo(None)p Ft(,)f(then)g Fo(sys.stdout)f Ft(is)i(used)0
2817 y(as)f(the)f(\002le)h(for)f(output.)0 3145 y Fm(6.7)121
b(The)34 b Fa(return)e Fm(statement)50 3376 y Fo(return_stmt)97
b Ft(::=)j Fo("return")48 b([expression_list])0 3524
y(return)20 b Ft(may)f(only)h(occur)f(syntactically)g(nested)h(in)h(a)f
(function)f(de\002nition,)f(not)i(within)g(a)h(nested)f(class)h
(de\002nition.)0 3671 y(If)f(an)g(e)o(xpression)f(list)i(is)g(present,)
e(it)i(is)h(e)n(v)n(aluated,)c(else)j Fo(None)f Ft(is)h(substituted.)0
3818 y Fo(return)f Ft(lea)n(v)o(es)g(the)g(current)f(function)f(call)j
(with)g(the)f(e)o(xpression)e(list)k(\(or)d Fo(None)p
Ft(\))h(as)h(return)e(v)n(alue.)0 3965 y(When)28 b Fo(return)f
Ft(passes)i(control)d(out)i(of)f(a)i Fo(try)f Ft(statement)f(with)h(a)h
Fo(finally)e Ft(clause,)j(that)e Fo(finally)f Ft(clause)h(is)g(e)o(x)o
(ecuted)0 4064 y(before)19 b(really)h(lea)n(ving)f(the)h(function.)0
4211 y(In)i(a)g(generator)e(function,)h(the)h Fo(return)f
Ft(statement)h(is)h(not)e(allo)n(wed)h(to)g(include)f(an)g
Fo(expression_list)p Ft(.)28 b(In)22 b(that)g(conte)o(xt,)f(a)0
4311 y(bare)f Fo(return)f Ft(indicates)h(that)g(the)h(generator)d(is)j
(done)e(and)h(will)h(cause)f Fo(StopIteration)e Ft(to)j(be)f(raised.)0
4638 y Fm(6.8)121 b(The)34 b Fa(yield)e Fm(statement)50
4870 y Fo(yield_stmt)98 b Ft(::=)h Fo(yield_expression)0
5018 y Ft(The)22 b Fo(yield)g Ft(statement)g(is)h(only)f(used)g(when)f
(de\002ning)g(a)i(generator)d(function,)h(and)h(is)h(only)f(used)g(in)g
(the)g(body)f(of)h(the)h(generator)0 5118 y(function.)32
b(Using)23 b(a)g Fo(yield)g Ft(statement)g(in)g(a)h(function)d
(de\002nition)h(is)i(suf)n(\002cient)f(to)g(cause)g(that)g
(de\002nition)f(to)h(create)g(a)h(generator)0 5217 y(function)18
b(instead)i(of)g(a)h(normal)e(function.)0 5364 y(When)d(a)h(generator)e
(function)g(is)i(called,)g(it)h(returns)d(an)i(iterator)f(kno)n(wn)f
(as)i(a)g(generator)e(iterator)m(,)h(or)g(more)g(commonly)-5
b(,)14 b(a)j(generator)-5 b(.)p 0 5549 3901 4 v 0 5649
a Fp(6.6.)52 b(The)23 b Fo(print)f Fp(statement)2816
b(57)p eop end
%%Page: 58 64
TeXDict begin 58 63 bop 0 83 a Ft(The)19 b(body)f(of)h(the)g(generator)
e(function)h(is)i(e)o(x)o(ecuted)e(by)h(calling)f(the)i(generator')-5
b(s)17 b Fo(next\(\))i Ft(method)f(repeatedly)g(until)h(it)h(raises)g
(an)0 183 y(e)o(xception.)0 330 y(When)k(a)h Fo(yield)f
Ft(statement)h(is)g(e)o(x)o(ecuted,)f(the)g(state)i(of)e(the)g
(generator)f(is)j(frozen)d(and)h(the)g(v)n(alue)g(of)g
Fo(expression_list)f Ft(is)0 429 y(returned)g(to)i Fo(next\(\))p
Ft(')-5 b(s)25 b(caller)-5 b(.)40 b(By)25 b(\223frozen\224)e(we)i(mean)
g(that)g(all)g(local)g(state)h(is)g(retained,)f(including)e(the)i
(current)e(bindings)h(of)0 529 y(local)d(v)n(ariables,)g(the)h
(instruction)e(pointer)m(,)g(and)h(the)g(internal)g(e)n(v)n(aluation)e
(stack:)28 b(enough)20 b(information)f(is)j(sa)n(v)o(ed)f(so)h(that)g
(the)f(ne)o(xt)0 628 y(time)f Fo(next\(\))g Ft(is)h(in)m(v)n(ok)o(ed,)d
(the)j(function)d(can)i(proceed)f(e)o(xactly)g(as)i(if)f(the)g
Fo(yield)g Ft(statement)g(were)g(just)h(another)e(e)o(xternal)g(call.)0
775 y(As)i(of)f(Python)f(v)o(ersion)g(2.5,)g(the)h Fo(yield)g
Ft(statement)g(is)h(no)n(w)f(allo)n(wed)f(in)h(the)h
Fo(try)f Ft(clause)g(of)g(a)g Fo(try)g Ft(...)g Fo(finally)g
Ft(construct.)k(If)0 875 y(the)e(generator)e(is)j(not)e(resumed)g
(before)f(it)j(is)g(\002nalized)e(\(by)g(reaching)f(a)j(zero)e
(reference)f(count)h(or)h(by)f(being)g(garbage)f(collected\),)0
975 y(the)g(generator)n(-iterator')-5 b(s)18 b Fo(close\(\))h
Ft(method)g(will)i(be)f(called,)g(allo)n(wing)f(an)o(y)g(pending)g
Fo(finally)g Ft(clauses)i(to)f(e)o(x)o(ecute.)0 1121
y Fr(Note:)27 b Ft(In)21 b(Python)f(2.2,)h(the)g Fo(yield)g
Ft(statement)g(is)i(only)d(allo)n(wed)h(when)g(the)g
Fo(generators)f Ft(feature)h(has)g(been)g(enabled.)27
b(It)22 b(will)0 1221 y(al)o(w)o(ays)f(be)f(enabled)f(in)h(Python)f
(2.3.)24 b(This)d Fo(__future__)e Ft(import)g(statement)h(can)g(be)g
(used)g(to)g(enable)g(the)g(feature:)236 1459 y Fi(from)44
b(__future__)g(import)f(generators)0 1789 y Fr(See)21
b(Also:)0 1936 y Ft(PEP)g(0255,)d(\223)p Fq(Simple)i(Gener)o(ator)o(s)p
Ft(\224)208 2035 y(The)f(proposal)g(for)h(adding)e(generators)h(and)h
(the)g Fo(yield)g Ft(statement)g(to)g(Python.)0 2182
y(PEP)h(0342,)d(\223)p Fq(Cor)l(outines)i(via)g(Enhanced)e(Gener)o
(ator)o(s)p Ft(\224)208 2282 y(The)k(proposal)g(that,)i(among)d(other)h
(generator)g(enhancements,)f(proposed)g(allo)n(wing)h
Fo(yield)h Ft(to)g(appear)f(inside)h(a)h Fo(try)f Ft(...)208
2381 y Fo(finally)c Ft(block.)0 2709 y Fm(6.9)121 b(The)34
b Fa(raise)e Fm(statement)50 2941 y Fo(raise_stmt)98
b Ft(::=)h Fo("raise")49 b([expression)e([",")j(expression)d([",")j
(expression]]])0 3088 y Ft(If)21 b(no)g(e)o(xpressions)g(are)g
(present,)g Fo(raise)g Ft(re-raises)g(the)h(last)g(e)o(xception)e(that)
h(w)o(as)h(acti)n(v)o(e)f(in)h(the)g(current)e(scope.)28
b(If)21 b(no)g(e)o(xception)0 3188 y(is)e(acti)n(v)o(e)e(in)i(the)f
(current)e(scope,)i(a)g Fo(TypeError)f Ft(e)o(xception)f(is)j(raised)f
(indicating)f(that)h(this)g(is)h(an)f(error)f(\(if)h(running)e(under)g
(IDLE,)0 3288 y(a)21 b Fo(Queue.Empty)d Ft(e)o(xception)h(is)i(raised)f
(instead\).)0 3435 y(Otherwise,)e Fo(raise)g Ft(e)n(v)n(aluates)f(the)h
(e)o(xpressions)e(to)j(get)f(three)f(objects,)h(using)f
Fo(None)h Ft(as)h(the)f(v)n(alue)f(of)h(omitted)f(e)o(xpressions.)23
b(The)0 3534 y(\002rst)e(tw)o(o)f(objects)g(are)g(used)g(to)h
(determine)e(the)h Fq(type)g Ft(and)f Fq(value)h Ft(of)g(the)g(e)o
(xception.)0 3681 y(If)k(the)g(\002rst)h(object)f(is)h(an)f(instance,)h
(the)f(type)g(of)g(the)g(e)o(xception)e(is)j(the)f(class)i(of)e(the)g
(instance,)g(the)h(instance)e(itself)i(is)g(the)f(v)n(alue,)0
3781 y(and)c(the)g(second)f(object)h(must)g(be)g Fo(None)p
Ft(.)0 3928 y(If)g(the)f(\002rst)i(object)e(is)i(a)f(class,)h(it)f
(becomes)f(the)h(type)f(of)h(the)g(e)o(xception.)i(The)e(second)f
(object)g(is)i(used)e(to)h(determine)f(the)g(e)o(xception)0
4027 y(v)n(alue:)32 b(If)23 b(it)i(is)g(an)e(instance)h(of)f(the)h
(class,)i(the)d(instance)h(becomes)f(the)g(e)o(xception)f(v)n(alue.)35
b(If)24 b(the)g(second)f(object)g(is)i(a)f(tuple,)g(it)h(is)0
4127 y(used)d(as)g(the)g(ar)o(gument)e(list)j(for)e(the)h(class)h
(constructor;)d(if)j(it)f(is)h Fo(None)p Ft(,)f(an)g(empty)f(ar)o
(gument)e(list)k(is)g(used,)f(and)f(an)o(y)g(other)g(object)0
4226 y(is)28 b(treated)e(as)i(a)g(single)e(ar)o(gument)f(to)i(the)g
(constructor)-5 b(.)44 b(The)27 b(instance)f(so)i(created)e(by)h
(calling)f(the)h(constructor)e(is)j(used)f(as)h(the)0
4326 y(e)o(xception)18 b(v)n(alue.)0 4473 y(If)h(a)h(third)e(object)h
(is)h(present)f(and)g(not)g Fo(None)p Ft(,)g(it)h(must)f(be)g(a)h
(traceback)e(object)h(\(see)g(section)g(3.2\),)f(and)h(it)h(is)g
(substituted)f(instead)g(of)0 4573 y(the)h(current)f(location)g(as)i
(the)f(place)g(where)f(the)h(e)o(xception)e(occurred.)23
b(If)d(the)g(third)g(object)f(is)i(present)f(and)f(not)h(a)g(traceback)
f(object)0 4672 y(or)j Fo(None)p Ft(,)h(a)g Fo(TypeError)e
Ft(e)o(xception)g(is)i(raised.)32 b(The)22 b(three-e)o(xpression)d
(form)j(of)g Fo(raise)g Ft(is)i(useful)d(to)i(re-raise)f(an)g(e)o
(xception)0 4772 y(transparently)e(in)h(an)h(e)o(xcept)e(clause,)i(b)n
(ut)g Fo(raise)f Ft(with)h(no)f(e)o(xpressions)f(should)g(be)i
(preferred)d(if)j(the)g(e)o(xception)d(to)j(be)g(re-raised)0
4871 y(w)o(as)f(the)f(most)g(recently)g(acti)n(v)o(e)f(e)o(xception)g
(in)h(the)g(current)f(scope.)0 5018 y(Additional)26 b(information)e(on)
j(e)o(xceptions)f(can)g(be)h(found)f(in)h(section)g(4.2,)h(and)e
(information)f(about)h(handling)f(e)o(xceptions)g(is)j(in)0
5118 y(section)20 b(7.4.)p 0 5549 3901 4 v 0 5649 a Fp(58)2663
b(Chapter)23 b(6.)52 b(Simple)25 b(statements)p eop end
%%Page: 59 65
TeXDict begin 59 64 bop 0 86 a Fm(6.10)121 b(The)34 b
Fa(break)e Fm(statement)50 318 y Fo(break_stmt)98 b Ft(::=)h
Fo("break")0 466 y(break)22 b Ft(may)g(only)f(occur)g(syntactically)h
(nested)g(in)g(a)h Fo(for)f Ft(or)g Fo(while)g Ft(loop,)g(b)n(ut)g(not)
g(nested)g(in)g(a)h(function)d(or)i(class)i(de\002nition)0
566 y(within)c(that)g(loop.)0 713 y(It)g(terminates)g(the)g(nearest)g
(enclosing)f(loop,)g(skipping)g(the)h(optional)f Fo(else)h
Ft(clause)g(if)h(the)f(loop)f(has)i(one.)0 859 y(If)f(a)h
Fo(for)f Ft(loop)f(is)i(terminated)e(by)h Fo(break)p
Ft(,)g(the)g(loop)f(control)g(tar)o(get)g(k)o(eeps)h(its)i(current)c(v)
n(alue.)0 1006 y(When)f Fo(break)g Ft(passes)h(control)e(out)h(of)h(a)f
Fo(try)h Ft(statement)f(with)g(a)h Fo(finally)f Ft(clause,)h(that)f
Fo(finally)g Ft(clause)g(is)h(e)o(x)o(ecuted)e(before)0
1106 y(really)k(lea)n(ving)f(the)i(loop.)0 1429 y Fm(6.11)121
b(The)34 b Fa(continue)d Fm(statement)50 1661 y Fo(continue_stmt)97
b Ft(::=)j Fo("continue")0 1809 y(continue)31 b Ft(may)h(only)f(occur)h
(syntactically)f(nested)h(in)g(a)h Fo(for)f Ft(or)g Fo(while)g
Ft(loop,)i(b)n(ut)e(not)g(nested)g(in)h(a)f(function)f(or)h(class)0
1909 y(de\002nition)19 b(or)h Fo(finally)f Ft(statement)h(within)g
(that)h(loop.)1686 1879 y Fg(1)1743 1909 y Ft(It)f(continues)f(with)i
(the)f(ne)o(xt)f(c)o(ycle)h(of)g(the)g(nearest)g(enclosing)f(loop.)0
2232 y Fm(6.12)121 b(The)34 b Fa(import)e Fm(statement)50
2462 y Fo(import_stmt)297 b Ft(::=)99 b Fo("import")49
b(module)f(["as")h(name])g(\()h(",")f(module)g(["as")f(name])h(\))3779
2477 y(*)1089 2562 y(|)h("from")f(relative_module)e("import")h
(identifier)g(["as")h(name])1139 2661 y(\()h(",")f(identifier)f(["as")h
(name])g(\))2634 2676 y(*)1089 2761 y(|)h("from")f(relative_module)e
("import")h("\(")h(identifier)f(["as")h(name])1139 2861
y(\()h(",")f(identifier)f(["as")h(name])g(\))2634 2876
y(*)2733 2861 y([","])g("\)")1089 2960 y(|)h("from")f(module)f
("import")h(")2385 2975 y(*)2435 2960 y(")50 3060 y(module)547
b Ft(::=)99 b Fo(\(identifier)48 b("."\))1887 3075 y(*)1986
3060 y(identifier)50 3159 y(relative_module)97 b Ft(::=)i
Fo(".")1239 3174 y(*)1338 3159 y(module)49 b(|)h("."+)50
3259 y(name)647 b Ft(::=)99 b Fo(identifier)0 3444 y
Ft(Import)26 b(statements)i(are)f(e)o(x)o(ecuted)f(in)i(tw)o(o)g
(steps:)40 b(\(1\))27 b(\002nd)h(a)g(module,)f(and)g(initialize)h(it)g
(if)g(necessary;)j(\(2\))c(de\002ne)g(a)h(name)f(or)0
3544 y(names)g(in)h(the)f(local)g(namespace)g(\(of)f(the)i(scope)f
(where)f(the)i Fo(import)f Ft(statement)g(occurs\).)45
b(The)27 b(\002rst)h(form)f(\(without)f Fo(from)p Ft(\))0
3643 y(repeats)21 b(these)h(steps)g(for)f(each)g(identi\002er)g(in)h
(the)f(list.)30 b(The)21 b(form)g(with)h Fo(from)f Ft(performs)f(step)i
(\(1\))f(once,)f(and)h(then)g(performs)f(step)0 3743
y(\(2\))g(repeatedly)-5 b(.)0 3890 y(In)24 b(this)i(conte)o(xt,)e(to)h
(\223initialize\224)g(a)g(b)n(uilt-in)f(or)g(e)o(xtension)g(module)f
(means)h(to)h(call)h(an)e(initialization)g(function)f(that)i(the)g
(module)0 3990 y(must)e(pro)o(vide)e(for)i(the)g(purpose)f(\(in)h(the)g
(reference)e(implementation,)h(the)h(function')-5 b(s)22
b(name)g(is)i(obtained)e(by)h(prepending)d(string)0 4089
y(\223init\224)g(to)h(the)f(module')-5 b(s)19 b(name\);)g(to)i
(\223initialize\224)f(a)g(Python-coded)d(module)i(means)h(to)g(e)o(x)o
(ecute)f(the)h(module')-5 b(s)19 b(body)-5 b(.)0 4236
y(The)21 b(system)h(maintains)e(a)i(table)f(of)g(modules)g(that)g(ha)n
(v)o(e)g(been)f(or)i(are)f(being)f(initialized,)h(inde)o(x)o(ed)e(by)i
(module)f(name.)28 b(This)22 b(table)0 4336 y(is)f(accessible)e(as)i
Fo(sys.modules)p Ft(.)i(When)d(a)g(module)e(name)h(is)i(found)d(in)h
(this)i(table,)e(step)h(\(1\))f(is)i(\002nished.)j(If)c(not,)f(a)h
(search)f(for)g(a)0 4435 y(module)d(de\002nition)f(is)j(started.)24
b(When)17 b(a)g(module)e(is)j(found,)e(it)h(is)h(loaded.)23
b(Details)18 b(of)e(the)h(module)f(searching)f(and)i(loading)e(process)
0 4535 y(are)20 b(implementation)e(and)h(platform)g(speci\002c.)25
b(It)20 b(generally)f(in)m(v)n(olv)o(es)g(searching)f(for)i(a)g(\223b)n
(uilt-in\224)f(module)g(with)h(the)g(gi)n(v)o(en)f(name)0
4635 y(and)h(then)f(searching)g(a)i(list)g(of)f(locations)g(gi)n(v)o
(en)f(as)h Fo(sys.path)p Ft(.)0 4781 y(If)j(a)g(b)n(uilt-in)f(module)g
(is)h(found,)f(its)i(b)n(uilt-in)e(initialization)g(code)g(is)i(e)o(x)o
(ecuted)d(and)h(step)h(\(1\))g(is)g(\002nished.)33 b(If)22
b(no)h(matching)e(\002le)j(is)0 4881 y(found,)f Fo(ImportError)g
Ft(is)i(raised.)36 b(If)24 b(a)g(\002le)h(is)g(found,)e(it)i(is)g
(parsed,)f(yielding)f(an)h(e)o(x)o(ecutable)e(code)h(block.)36
b(If)24 b(a)g(syntax)g(error)0 4981 y(occurs,)16 b Fo(SyntaxError)g
Ft(is)h(raised.)24 b(Otherwise,)17 b(an)f(empty)g(module)f(of)i(the)f
(gi)n(v)o(en)g(name)g(is)h(created)f(and)g(inserted)g(in)h(the)g
(module)0 5080 y(table,)25 b(and)e(then)h(the)g(code)f(block)g(is)i(e)o
(x)o(ecuted)d(in)j(the)f(conte)o(xt)f(of)g(this)i(module.)35
b(Exceptions)23 b(during)f(this)j(e)o(x)o(ecution)c(terminate)0
5180 y(step)g(\(1\).)p 0 5242 1560 4 v 90 5298 a Ff(1)120
5321 y Fl(It)c(may)h(occur)h(within)g(an)f Fb(except)e
Fl(or)i Fb(else)f Fl(clause.)24 b(The)17 b(restriction)k(on)d
(occurring)h(in)f(the)h Fb(try)e Fl(clause)i(is)f(implementor')l(s)i
(laziness)f(and)f(will)h(e)n(v)o(entually)0 5400 y(be)e(lifted.)p
0 5549 3901 4 v 0 5649 a Fp(6.10.)52 b(The)23 b Fo(break)g
Fp(statement)2769 b(59)p eop end
%%Page: 60 66
TeXDict begin 60 65 bop 0 83 a Ft(When)20 b(step)h(\(1\))e(\002nishes)i
(without)e(raising)h(an)g(e)o(xception,)e(step)i(\(2\))g(can)g(be)o
(gin.)0 230 y(The)25 b(\002rst)h(form)e(of)h Fo(import)f
Ft(statement)h(binds)g(the)g(module)f(name)h(in)g(the)g(local)g
(namespace)f(to)i(the)f(module)f(object,)h(and)g(then)0
330 y(goes)c(on)g(to)h(import)f(the)g(ne)o(xt)g(identi\002er)m(,)g(if)h
(an)o(y)-5 b(.)28 b(If)21 b(the)h(module)e(name)h(is)h(follo)n(wed)f
(by)g Fo(as)p Ft(,)h(the)f(name)g(follo)n(wing)f Fo(as)i
Ft(is)h(used)e(as)0 429 y(the)f(local)g(name)g(for)f(the)i(module.)0
576 y(The)i Fo(from)g Ft(form)f(does)i(not)f(bind)f(the)h(module)f
(name:)31 b(it)24 b(goes)f(through)f(the)h(list)h(of)f(identi\002ers,)h
(looks)f(each)g(one)f(of)i(them)e(up)h(in)0 676 y(the)i(module)e(found)
g(in)j(step)f(\(1\),)g(and)f(binds)g(the)h(name)g(in)g(the)g(local)f
(namespace)g(to)h(the)g(object)f(thus)h(found.)37 b(As)26
b(with)f(the)g(\002rst)0 775 y(form)i(of)g Fo(import)p
Ft(,)i(an)e(alternate)g(local)h(name)f(can)g(be)h(supplied)e(by)i
(specifying)e(\224)p Fo(as)h Ft(localname\224.)46 b(If)28
b(a)g(name)f(is)h(not)g(found,)0 875 y Fo(ImportError)22
b Ft(is)j(raised.)35 b(If)24 b(the)f(list)i(of)f(identi\002ers)f(is)i
(replaced)d(by)i(a)g(star)g(\(`)2442 890 y Fo(*)2492
875 y Ft('\),)f(all)h(public)f(names)h(de\002ned)e(in)i(the)g(module)0
975 y(are)c(bound)e(in)j(the)f(local)g(namespace)f(of)h(the)g
Fo(import)g Ft(statement..)0 1121 y(The)28 b Fq(public)f(names)h
Ft(de\002ned)f(by)h(a)h(module)e(are)h(determined)e(by)i(checking)f
(the)h(module')-5 b(s)27 b(namespace)g(for)h(a)h(v)n(ariable)e(named)0
1221 y Fo(__all__)p Ft(;)j(if)e(de\002ned,)g(it)h(must)e(be)h(a)g
(sequence)e(of)h(strings)h(which)f(are)g(names)g(de\002ned)g(or)g
(imported)f(by)h(that)g(module.)46 b(The)0 1321 y(names)24
b(gi)n(v)o(en)f(in)h Fo(__all__)g Ft(are)g(all)h(considered)d(public)h
(and)h(are)g(required)f(to)h(e)o(xist.)37 b(If)24 b Fo(__all__)g
Ft(is)h(not)f(de\002ned,)g(the)g(set)h(of)0 1420 y(public)e(names)g
(includes)g(all)h(names)f(found)f(in)i(the)f(module')-5
b(s)23 b(namespace)f(which)h(do)h(not)f(be)o(gin)f(with)i(an)f
(underscore)f(character)0 1520 y(\(`)p Fo(_)p Ft('\).)j
Fo(__all__)19 b Ft(should)h(contain)f(the)i(entire)f(public)f(API.)i
(It)g(is)g(intended)e(to)i(a)n(v)n(oid)f(accidentally)f(e)o(xporting)f
(items)j(that)g(are)f(not)0 1620 y(part)g(of)g(the)g(API)g(\(such)g(as)
h(library)e(modules)g(which)h(were)g(imported)e(and)i(used)g(within)g
(the)g(module\).)0 1766 y(The)27 b Fo(from)g Ft(form)f(with)i(`)777
1781 y Fo(*)827 1766 y Ft(')f(may)f(only)h(occur)f(in)h(a)h(module)e
(scope.)46 b(If)27 b(the)g(wild)g(card)g(form)f(of)h(import)g(\227)g(`)
p Fo(import)3712 1781 y(*)3762 1766 y Ft(')g(\227)0 1866
y(is)32 b(used)f(in)g(a)h(function)d(and)h(the)i(function)d(contains)h
(or)h(is)h(a)g(nested)e(block)g(with)i(free)e(v)n(ariables,)j(the)e
(compiler)f(will)i(raise)f(a)0 1966 y Fo(SyntaxError)p
Ft(.)0 2113 y Fr(Hierar)o(chical)21 b(module)j(names:)31
b Ft(when)22 b(the)h(module)f(names)g(contains)g(one)h(or)g(more)f
(dots,)h(the)g(module)f(search)g(path)h(is)h(carried)0
2212 y(out)h(dif)n(ferently)-5 b(.)39 b(The)26 b(sequence)e(of)i
(identi\002ers)f(up)h(to)f(the)h(last)h(dot)e(is)i(used)e(to)h(\002nd)g
(a)g(\223package\224;)h(the)e(\002nal)h(identi\002er)f(is)i(then)0
2312 y(searched)16 b(inside)i(the)f(package.)23 b(A)17
b(package)f(is)j(generally)d(a)h(subdirectory)e(of)j(a)f(directory)f
(on)h Fo(sys.path)f Ft(that)i(has)g(a)f(\002le)h(`)p
3676 2312 23 4 v 3703 2312 V 54 w Fu(init)p 3827 2312
V 3853 2312 V 52 w(-)0 2411 y(.p)n(y)p Ft('.)23 b([XXX)17
b(Can')o(t)e(be)i(bothered)d(to)j(spell)f(this)h(out)f(right)g(no)n(w;)
h(see)g(the)f(URL)h Fu(
http://www)l(.p)n(ython.org/d)o(oc/e)o(ssa)n
(ys/pac)o(kag)o(es)o(.h)o(tml)0 2511 y Ft(for)j(more)f(details,)h(also)
h(about)e(ho)n(w)h(the)g(module)f(search)g(w)o(orks)h(from)f(inside)h
(a)h(package.])0 2658 y(The)h(b)n(uilt-in)g(function)f
Fo(__import__\(\))g Ft(is)j(pro)o(vided)c(to)j(support)e(applications)h
(that)h(determine)e(which)h(modules)g(need)g(to)h(be)0
2758 y(loaded)c(dynamically;)f(refer)i(to)g(Built-in)g(Functions)g(in)g
(the)g Fq(Python)f(Libr)o(ary)h(Refer)m(ence)g Ft(for)f(additional)g
(information.)0 3042 y Fk(6.12.1)101 b(Future)28 b(statements)0
3245 y Ft(A)19 b Fq(futur)m(e)f(statement)g Ft(is)h(a)f(directi)n(v)o
(e)f(to)h(the)g(compiler)f(that)i(a)f(particular)f(module)g(should)g
(be)h(compiled)f(using)g(syntax)h(or)g(semantics)0 3345
y(that)27 b(will)h(be)e(a)n(v)n(ailable)h(in)g(a)g(speci\002ed)g
(future)e(release)i(of)g(Python.)44 b(The)26 b(future)g(statement)h(is)
g(intended)f(to)h(ease)g(migration)e(to)0 3445 y(future)c(v)o(ersions)f
(of)i(Python)e(that)i(introduce)e(incompatible)g(changes)g(to)i(the)g
(language.)27 b(It)22 b(allo)n(ws)g(use)g(of)g(the)f(ne)n(w)h(features)
f(on)g(a)0 3544 y(per)n(-module)d(basis)j(before)d(the)j(release)f(in)g
(which)g(the)g(feature)f(becomes)h(standard.)216 3687
y Fo(future_statement)96 b Ft(::=)k Fo("from")49 b("__future__")e
("import")i(feature)f(["as")h(name])1355 3787 y(\(",")g(feature)f
(["as")h(name]\))2601 3802 y(*)1305 3887 y(|)h("from")e("__future__")g
("import")g("\(")i(feature)e(["as")h(name])1355 3986
y(\(",")g(feature)f(["as")h(name]\))2601 4001 y(*)2700
3986 y([","])g("\)")216 4086 y(feature)546 b Ft(::=)100
b Fo(identifier)216 4186 y(name)696 b Ft(::=)100 b Fo(identifier)0
4371 y Ft(A)24 b(future)e(statement)h(must)h(appear)e(near)h(the)g(top)
g(of)g(the)h(module.)33 b(The)23 b(only)f(lines)i(that)f(can)h(appear)e
(before)g(a)i(future)e(statement)0 4470 y(are:)125 4700
y Fs(\017)41 b Ft(the)20 b(module)f(docstring)f(\(if)i(an)o(y\),)125
4866 y Fs(\017)41 b Ft(comments,)125 5032 y Fs(\017)g
Ft(blank)19 b(lines,)h(and)125 5198 y Fs(\017)41 b Ft(other)19
b(future)g(statements.)p 0 5549 3901 4 v 0 5649 a Fp(60)2663
b(Chapter)23 b(6.)52 b(Simple)25 b(statements)p eop end
%%Page: 61 67
TeXDict begin 61 66 bop 0 83 a Ft(The)31 b(features)f(recognized)e(by)j
(Python)f(2.5)g(are)h(`)p Fo(absolute_import)p Ft(',)f(`)p
Fo(division)p Ft(',)i(`)p Fo(generators)p Ft(',)f(`)p
Fo(nested_-)0 183 y(scopes)p Ft(')18 b(and)h(`)p Fo(with_statement)p
Ft('.)j(`)p Fo(generators)p Ft(')17 b(and)i(`)p Fo(nested_scopes)p
Ft(')e(are)i(redundant)e(in)i(Python)f(v)o(ersion)g(2.3)0
282 y(and)i(abo)o(v)o(e)e(because)i(the)o(y)f(are)h(al)o(w)o(ays)h
(enabled.)0 429 y(A)k(future)e(statement)i(is)g(recognized)e(and)h
(treated)g(specially)g(at)h(compile)f(time:)34 b(Changes)24
b(to)h(the)f(semantics)h(of)f(core)g(constructs)0 529
y(are)19 b(often)g(implemented)e(by)i(generating)f(dif)n(ferent)f
(code.)24 b(It)c(may)f(e)n(v)o(en)f(be)i(the)f(case)h(that)f(a)h(ne)n
(w)f(feature)g(introduces)f(ne)n(w)h(incom-)0 628 y(patible)24
b(syntax)g(\(such)g(as)h(a)g(ne)n(w)f(reserv)o(ed)f(w)o(ord\),)h(in)h
(which)f(case)h(the)f(compiler)f(may)h(need)g(to)h(parse)f(the)g
(module)f(dif)n(ferently)-5 b(.)0 728 y(Such)20 b(decisions)g(cannot)f
(be)h(pushed)f(of)n(f)g(until)h(runtime.)0 875 y(F)o(or)h(an)o(y)g(gi)n
(v)o(en)g(release,)h(the)f(compiler)g(kno)n(ws)g(which)g(feature)g
(names)g(ha)n(v)o(e)g(been)g(de\002ned,)g(and)g(raises)i(a)f
(compile-time)e(error)g(if)0 975 y(a)h(future)e(statement)h(contains)f
(a)i(feature)e(not)h(kno)n(wn)e(to)j(it.)0 1121 y(The)26
b(direct)g(runtime)f(semantics)h(are)h(the)f(same)g(as)h(for)f(an)o(y)g
(import)f(statement:)37 b(there)26 b(is)h(a)g(standard)e(module)g
Fo(__future__)p Ft(,)0 1221 y(described)19 b(later)m(,)h(and)f(it)i
(will)g(be)f(imported)f(in)h(the)g(usual)g(w)o(ay)h(at)f(the)g(time)h
(the)f(future)f(statement)h(is)h(e)o(x)o(ecuted.)0 1368
y(The)f(interesting)f(runtime)g(semantics)h(depend)f(on)h(the)g
(speci\002c)g(feature)f(enabled)g(by)h(the)g(future)f(statement.)0
1515 y(Note)h(that)g(there)g(is)h(nothing)e(special)h(about)f(the)h
(statement:)236 1662 y Fi(import)44 b(__future__)f([as)i(name])0
1948 y Ft(That)20 b(is)h(not)f(a)h(future)e(statement;)h(it')-5
b(s)21 b(an)f(ordinary)e(import)h(statement)h(with)h(no)e(special)i
(semantics)f(or)g(syntax)f(restrictions.)0 2095 y(Code)27
b(compiled)g(by)g(an)g Fo(exec)h Ft(statement)f(or)g(calls)h(to)g(the)g
(b)n(uiltin)f(functions)f Fo(compile\(\))h Ft(and)g Fo(execfile\(\))f
Ft(that)i(occur)0 2195 y(in)h(a)g(module)e Fo(M)i Ft(containing)e(a)i
(future)f(statement)g(will,)k(by)c(def)o(ault,)i(use)f(the)f(ne)n(w)h
(syntax)f(or)g(semantics)h(associated)g(with)g(the)0
2294 y(future)23 b(statement.)35 b(This)24 b(can,)g(starting)f(with)h
(Python)f(2.2)g(be)g(controlled)f(by)h(optional)g(ar)o(guments)f(to)h
Fo(compile\(\))g Ft(\227)h(see)h(the)0 2394 y(documentation)17
b(of)j(that)g(function)f(in)h(the)g Fq(Python)f(Libr)o(ary)i(Refer)m
(ence)e Ft(for)h(details.)0 2541 y(A)f(future)e(statement)h(typed)g(at)
h(an)f(interacti)n(v)o(e)f(interpreter)g(prompt)g(will)i(tak)o(e)f(ef)n
(fect)g(for)g(the)g(rest)h(of)f(the)h(interpreter)e(session.)24
b(If)19 b(an)0 2640 y(interpreter)f(is)j(started)f(with)g(the)f
Fr(-i)h Ft(option,)f(is)i(passed)e(a)h(script)g(name)f(to)h(e)o(x)o
(ecute,)f(and)g(the)h(script)g(includes)f(a)h(future)e(statement,)i(it)
0 2740 y(will)h(be)f(in)g(ef)n(fect)g(in)g(the)h(interacti)n(v)o(e)d
(session)j(started)f(after)g(the)g(script)g(is)i(e)o(x)o(ecuted.)0
3067 y Fm(6.13)121 b(The)34 b Fa(global)e Fm(statement)50
3299 y Fo(global_stmt)97 b Ft(::=)j Fo("global")48 b(identifier)g
(\(",")h(identifier\))2685 3314 y(*)0 3447 y Ft(The)16
b Fo(global)f Ft(statement)h(is)h(a)g(declaration)d(which)i(holds)g
(for)f(the)h(entire)g(current)f(code)g(block.)23 b(It)16
b(means)g(that)g(the)g(listed)h(identi\002ers)0 3547
y(are)22 b(to)f(be)h(interpreted)e(as)i(globals.)29 b(It)22
b(w)o(ould)f(be)h(impossible)f(to)h(assign)g(to)f(a)i(global)d(v)n
(ariable)h(without)g Fo(global)p Ft(,)g(although)f(free)0
3646 y(v)n(ariables)f(may)h(refer)g(to)g(globals)f(without)h(being)f
(declared)g(global.)0 3793 y(Names)30 b(listed)h(in)g(a)f
Fo(global)g Ft(statement)g(must)g(not)g(be)g(used)g(in)h(the)f(same)h
(code)e(block)g(te)o(xtually)h(preceding)e(that)i Fo(global)0
3893 y Ft(statement.)0 4040 y(Names)18 b(listed)g(in)g(a)g
Fo(global)f Ft(statement)h(must)f(not)h(be)f(de\002ned)g(as)h(formal)f
(parameters)f(or)i(in)g(a)g Fo(for)g Ft(loop)e(control)h(tar)o(get,)g
Fo(class)0 4139 y Ft(de\002nition,)i(function)f(de\002nition,)h(or)h
Fo(import)g Ft(statement.)0 4286 y(\(The)g(current)g(implementation)f
(does)h(not)h(enforce)e(the)i(latter)g(tw)o(o)g(restrictions,)g(b)n(ut)
g(programs)e(should)h(not)g(ab)n(use)h(this)h(freedom,)0
4386 y(as)f(future)e(implementations)f(may)i(enforce)f(them)g(or)h
(silently)h(change)d(the)j(meaning)d(of)i(the)g(program.\))0
4533 y Fr(Pr)o(ogrammer')m(s)h(note:)31 b Ft(the)23 b
Fo(global)f Ft(is)j(a)e(directi)n(v)o(e)f(to)h(the)h(parser)-5
b(.)33 b(It)24 b(applies)f(only)f(to)h(code)g(parsed)f(at)i(the)f(same)
g(time)h(as)g(the)0 4632 y Fo(global)18 b Ft(statement.)24
b(In)19 b(particular)m(,)e(a)i Fo(global)f Ft(statement)g(contained)f
(in)i(an)f Fo(exec)h Ft(statement)f(does)h(not)f(af)n(fect)g(the)h
(code)f(block)0 4732 y Fq(containing)f Ft(the)j Fo(exec)f
Ft(statement,)h(and)f(code)g(contained)f(in)h(an)h Fo(exec)f
Ft(statement)h(is)g(unaf)n(fected)e(by)h Fo(global)g
Ft(statements)h(in)g(the)0 4832 y(code)f(containing)e(the)j
Fo(exec)f Ft(statement.)24 b(The)19 b(same)h(applies)f(to)h(the)f
Fo(eval\(\))p Ft(,)g Fo(execfile\(\))f Ft(and)h Fo(compile\(\))f
Ft(functions.)p 0 5549 3901 4 v 0 5649 a Fp(6.13.)52
b(The)23 b Fo(global)f Fp(statement)2720 b(61)p eop end
%%Page: 62 68
TeXDict begin 62 67 bop 0 86 a Fm(6.14)121 b(The)34 b
Fa(exec)f Fm(statement)50 318 y Fo(exec_stmt)98 b Ft(::=)h
Fo("exec")49 b(or_expr)g(["in")f(expression)g([",")h(expression]])0
466 y Ft(This)22 b(statement)f(supports)f(dynamic)g(e)o(x)o(ecution)f
(of)i(Python)f(code.)28 b(The)21 b(\002rst)h(e)o(xpression)e(should)g
(e)n(v)n(aluate)g(to)i(either)f(a)h(string,)f(an)0 566
y(open)j(\002le)i(object,)g(or)f(a)h(code)e(object.)40
b(If)25 b(it)h(is)g(a)g(string,)g(the)f(string)g(is)h(parsed)e(as)i(a)g
(suite)g(of)f(Python)f(statements)h(which)g(is)h(then)0
665 y(e)o(x)o(ecuted)c(\(unless)i(a)g(syntax)g(error)e(occurs\).)36
b(If)24 b(it)g(is)h(an)f(open)f(\002le,)i(the)f(\002le)h(is)g(parsed)e
(until)j Fl(E)t(O)t(F)g Ft(and)e(e)o(x)o(ecuted.)34 b(If)24
b(it)h(is)g(a)f(code)0 765 y(object,)19 b(it)i(is)g(simply)f(e)o(x)o
(ecuted.)j(In)d(all)h(cases,)g(the)f(code)f(that')-5
b(s)21 b(e)o(x)o(ecuted)d(is)j(e)o(xpected)e(to)h(be)g(v)n(alid)g(as)h
(\002le)g(input)e(\(see)i(section)e(8.2,)0 865 y(\223File)i
(input\224\).)i(Be)e(a)o(w)o(are)f(that)g(the)g Fo(return)g
Ft(and)f Fo(yield)h Ft(statements)g(may)f(not)h(be)g(used)g(outside)f
(of)h(function)e(de\002nitions)i(e)n(v)o(en)0 964 y(within)g(the)g
(conte)o(xt)f(of)h(code)g(passed)g(to)g(the)g Fo(exec)g
Ft(statement.)0 1111 y(In)26 b(all)h(cases,)h(if)f(the)f(optional)g
(parts)g(are)g(omitted,)h(the)f(code)g(is)h(e)o(x)o(ecuted)e(in)h(the)h
(current)e(scope.)43 b(If)26 b(only)g(the)g(\002rst)h(e)o(xpression)0
1211 y(after)c Fo(in)h Ft(is)h(speci\002ed,)f(it)g(should)f(be)g(a)h
(dictionary)-5 b(,)22 b(which)h(will)i(be)e(used)h(for)f(both)g(the)g
(global)g(and)g(the)h(local)f(v)n(ariables.)35 b(If)23
b(tw)o(o)0 1310 y(e)o(xpressions)j(are)g(gi)n(v)o(en,)h(the)o(y)f(are)h
(used)g(for)f(the)h(global)f(and)g(local)h(v)n(ariables,)g(respecti)n
(v)o(ely)-5 b(.)43 b(If)27 b(pro)o(vided,)e Fq(locals)i
Ft(can)g(be)f(an)o(y)0 1410 y(mapping)18 b(object.)50
b(Changed)19 b(in)i(v)o(ersion)e(2.4:)g(formerly)f Fq(locals)j
Ft(w)o(as)g(required)d(to)i(be)g(a)h(dictionary)-5 b(.)0
1557 y(As)21 b(a)f(side)g(ef)n(fect,)f(an)h(implementation)e(may)h
(insert)h(additional)e(k)o(e)o(ys)i(into)f(the)h(dictionaries)f(gi)n(v)
o(en)g(besides)g(those)h(corresponding)0 1656 y(to)30
b(v)n(ariable)e(names)h(set)h(by)f(the)g(e)o(x)o(ecuted)f(code.)51
b(F)o(or)29 b(e)o(xample,)h(the)g(current)e(implementation)f(may)i(add)
g(a)g(reference)f(to)i(the)0 1756 y(dictionary)18 b(of)i(the)h(b)n
(uilt-in)e(module)g Fo(__builtin__)g Ft(under)f(the)j(k)o(e)o(y)e
Fo(__builtins__)g Ft(\(!\).)0 1903 y Fr(Pr)o(ogrammer')m(s)g(hints:)28
b Ft(dynamic)20 b(e)n(v)n(aluation)g(of)h(e)o(xpressions)f(is)i
(supported)d(by)i(the)g(b)n(uilt-in)g(function)f Fo(eval\(\))p
Ft(.)27 b(The)21 b(b)n(uilt-in)0 2003 y(functions)27
b Fo(globals\(\))g Ft(and)h Fo(locals\(\))g Ft(return)f(the)i(current)e
(global)h(and)g(local)g(dictionary)-5 b(,)28 b(respecti)n(v)o(ely)-5
b(,)29 b(which)f(may)g(be)0 2102 y(useful)20 b(to)g(pass)h(around)d
(for)i(use)g(by)g Fo(exec)p Ft(.)p 0 5549 3901 4 v 0
5649 a Fp(62)2663 b(Chapter)23 b(6.)52 b(Simple)25 b(statements)p
eop end
%%Page: 63 69
TeXDict begin 63 68 bop 0 83 3901 9 v 3503 230 a Fp(CHAPTER)3495
427 y Fn(SEVEN)p 0 515 V 1822 978 a Fz(Compound)57 b(statements)0
1465 y Ft(Compound)21 b(statements)j(contain)f(\(groups)f(of\))h(other)
g(statements;)j(the)o(y)d(af)n(fect)g(or)h(control)f(the)g(e)o(x)o
(ecution)f(of)i(those)f(other)g(state-)0 1565 y(ments)j(in)g(some)g(w)o
(ay)-5 b(.)42 b(In)26 b(general,)g(compound)d(statements)j(span)g
(multiple)f(lines,)j(although)c(in)i(simple)g(incarnations)f(a)h(whole)
0 1664 y(compound)17 b(statement)j(may)g(be)g(contained)f(in)h(one)g
(line.)0 1811 y(The)29 b Fo(if)p Ft(,)i Fo(while)e Ft(and)g
Fo(for)g Ft(statements)g(implement)f(traditional)h(control)f(\003o)n(w)
h(constructs.)51 b Fo(try)29 b Ft(speci\002es)h(e)o(xception)d(han-)0
1911 y(dlers)d(and/or)f(cleanup)g(code)h(for)g(a)g(group)f(of)h
(statements.)37 b(Function)24 b(and)f(class)j(de\002nitions)d(are)h
(also)h(syntactically)e(compound)0 2010 y(statements.)0
2157 y(Compound)16 b(statements)j(consist)g(of)g(one)f(or)g(more)g
(`clauses.)-6 b(')25 b(A)19 b(clause)g(consists)g(of)g(a)g(header)e
(and)i(a)g(`suite.)-6 b(')24 b(The)19 b(clause)f(headers)0
2257 y(of)24 b(a)g(particular)f(compound)e(statement)i(are)h(all)h(at)f
(the)g(same)g(indentation)e(le)n(v)o(el.)36 b(Each)23
b(clause)h(header)f(be)o(gins)g(with)h(a)g(uniquely)0
2357 y(identifying)17 b(k)o(e)o(yw)o(ord)h(and)h(ends)g(with)g(a)h
(colon.)k(A)19 b(suite)h(is)g(a)g(group)e(of)h(statements)g(controlled)
f(by)h(a)g(clause.)25 b(A)20 b(suite)g(can)f(be)g(one)0
2456 y(or)h(more)g(semicolon-separated)e(simple)j(statements)f(on)h
(the)f(same)h(line)g(as)g(the)g(header)m(,)e(follo)n(wing)g(the)i
(header')-5 b(s)19 b(colon,)h(or)g(it)i(can)0 2556 y(be)i(one)f(or)g
(more)g(indented)f(statements)i(on)f(subsequent)f(lines.)36
b(Only)23 b(the)h(latter)g(form)f(of)g(suite)h(can)f(contain)g(nested)g
(compound)0 2655 y(statements;)g(the)g(follo)n(wing)d(is)j(ille)o(gal,)
f(mostly)g(because)f(it)i(w)o(ouldn')o(t)e(be)h(clear)g(to)g(which)g
Fo(if)g Ft(clause)g(a)h(follo)n(wing)e Fo(else)h Ft(clause)0
2755 y(w)o(ould)d(belong:)236 2993 y Fi(if)45 b(test1:)f(if)g(test2:)g
(print)g(x)0 3280 y Ft(Also)20 b(note)g(that)g(the)g(semicolon)f(binds)
g(tighter)h(than)f(the)h(colon)f(in)h(this)h(conte)o(xt,)d(so)j(that)f
(in)g(the)g(follo)n(wing)e(e)o(xample,)h(either)g(all)i(or)0
3379 y(none)e(of)h(the)g Fo(print)g Ft(statements)g(are)g(e)o(x)o
(ecuted:)236 3618 y Fi(if)45 b(x)f(<)h(y)g(<)f(z:)h(print)f(x;)g(print)
g(y;)h(print)f(z)0 3904 y Ft(Summarizing:)216 4047 y
Fo(compound_stmt)97 b Ft(::=)j Fo(if_stmt)1156 4147 y(|)49
b(while_stmt)1156 4247 y(|)g(for_stmt)1156 4346 y(|)g(try_stmt)1156
4446 y(|)g(with_stmt)1156 4545 y(|)g(funcdef)1156 4645
y(|)g(classdef)216 4745 y(suite)497 b Ft(::=)100 b Fo(stmt_list)48
b(NEWLINE)g(|)i(NEWLINE)e(INDENT)h(statement+)f(DEDENT)216
4844 y(statement)297 b Ft(::=)100 b Fo(stmt_list)48 b(NEWLINE)g(|)i
(compound_stmt)216 4944 y(stmt_list)297 b Ft(::=)100
b Fo(simple_stmt)47 b(\(";")i(simple_stmt\))2602 4959
y(*)2700 4944 y([";"])0 5086 y Ft(Note)20 b(that)f(statements)h(al)o(w)
o(ays)g(end)f(in)h(a)g Fo(NEWLINE)f Ft(possibly)g(follo)n(wed)f(by)i(a)
g Fo(DEDENT)p Ft(.)f(Also)h(note)f(that)h(optional)e(continuation)0
5186 y(clauses)i(al)o(w)o(ays)g(be)o(gin)e(with)i(a)g(k)o(e)o(yw)o(ord)
d(that)j(cannot)e(start)i(a)g(statement,)f(thus)h(there)f(are)g(no)g
(ambiguities)g(\(the)g(`dangling)e Fo(else)p Ft(')0 5285
y(problem)h(is)k(solv)o(ed)d(in)h(Python)f(by)h(requiring)e(nested)i
Fo(if)g Ft(statements)h(to)f(be)g(indented\).)p 0 5549
3901 4 v 3808 5649 a Fp(63)p eop end
%%Page: 64 70
TeXDict begin 64 69 bop 0 83 a Ft(The)20 b(formatting)e(of)i(the)g
(grammar)f(rules)h(in)g(the)g(follo)n(wing)f(sections)h(places)g(each)g
(clause)h(on)e(a)i(separate)f(line)g(for)f(clarity)-5
b(.)0 410 y Fm(7.1)121 b(The)34 b Fa(if)f Fm(statement)0
643 y Ft(The)20 b Fo(if)g Ft(statement)g(is)h(used)f(for)g(conditional)
e(e)o(x)o(ecution:)216 770 y Fo(if_stmt)98 b Ft(::=)i
Fo("if")49 b(expression)f(":")h(suite)857 869 y(\()g("elif")g
(expression)f(":")h(suite)g(\))2401 884 y(*)857 969 y(["else")f(":")i
(suite])0 1111 y Ft(It)16 b(selects)g(e)o(xactly)e(one)h(of)g(the)h
(suites)g(by)f(e)n(v)n(aluating)f(the)h(e)o(xpressions)f(one)h(by)g
(one)g(until)g(one)g(is)h(found)e(to)i(be)f(true)g(\(see)h(section)f
(5.10)0 1210 y(for)24 b(the)g(de\002nition)f(of)h(true)g(and)g(f)o
(alse\);)j(then)d(that)g(suite)h(is)g(e)o(x)o(ecuted)e(\(and)g(no)h
(other)g(part)g(of)g(the)g Fo(if)h Ft(statement)f(is)h(e)o(x)o(ecuted)e
(or)0 1310 y(e)n(v)n(aluated\).)g(If)d(all)h(e)o(xpressions)e(are)h(f)o
(alse,)g(the)h(suite)f(of)g(the)g Fo(else)g Ft(clause,)g(if)h(present,)
e(is)i(e)o(x)o(ecuted.)0 1638 y Fm(7.2)121 b(The)34 b
Fa(while)e Fm(statement)0 1870 y Ft(The)20 b Fo(while)g
Ft(statement)g(is)h(used)f(for)f(repeated)g(e)o(x)o(ecution)f(as)j
(long)f(as)g(an)h(e)o(xpression)d(is)j(true:)216 2014
y Fo(while_stmt)98 b Ft(::=)h Fo("while")49 b(expression)f(":")h(suite)
1006 2113 y(["else")g(":")g(suite])0 2255 y Ft(This)23
b(repeatedly)f(tests)i(the)f(e)o(xpression)e(and,)i(if)g(it)h(is)g
(true,)f(e)o(x)o(ecutes)f(the)h(\002rst)h(suite;)h(if)e(the)g(e)o
(xpression)f(is)h(f)o(alse)h(\(which)e(may)h(be)0 2355
y(the)d(\002rst)h(time)g(it)f(is)i(tested\))e(the)g(suite)g(of)g(the)h
Fo(else)f Ft(clause,)g(if)g(present,)f(is)i(e)o(x)o(ecuted)e(and)g(the)
i(loop)e(terminates.)0 2502 y(A)31 b Fo(break)g Ft(statement)f(e)o(x)o
(ecuted)f(in)i(the)g(\002rst)g(suite)g(terminates)f(the)h(loop)f
(without)g(e)o(x)o(ecuting)f(the)h Fo(else)h Ft(clause')-5
b(s)31 b(suite.)57 b(A)0 2601 y Fo(continue)19 b Ft(statement)h(e)o(x)o
(ecuted)f(in)h(the)g(\002rst)h(suite)g(skips)f(the)g(rest)h(of)f(the)g
(suite)h(and)e(goes)h(back)g(to)g(testing)g(the)g(e)o(xpression.)0
2929 y Fm(7.3)121 b(The)34 b Fa(for)e Fm(statement)0
3162 y Ft(The)23 b Fo(for)g Ft(statement)g(is)h(used)f(to)g(iterate)g
(o)o(v)o(er)f(the)h(elements)g(of)g(a)h(sequence)e(\(such)g(as)i(a)g
(string,)f(tuple)g(or)g(list\))h(or)f(other)f(iterable)0
3261 y(object:)216 3404 y Fo(for_stmt)98 b Ft(::=)i Fo("for")48
b(target_list)g("in")h(expression_list)e(":")j(suite)907
3504 y(["else")e(":")h(suite])0 3646 y Ft(The)27 b(e)o(xpression)g
(list)i(is)f(e)n(v)n(aluated)f(once;)k(it)d(should)f(yield)h(an)f
(iterable)h(object.)47 b(An)28 b(iterator)f(is)i(created)e(for)g(the)h
(result)g(of)g(the)0 3746 y Fo(expression_list)p Ft(.)22
b(The)16 b(suite)i(is)g(then)e(e)o(x)o(ecuted)f(once)i(for)f(each)h
(item)g(pro)o(vided)d(by)j(the)g(iterator)m(,)f(in)i(the)f(order)e(of)i
(ascending)0 3845 y(indices.)34 b(Each)23 b(item)g(in)g(turn)g(is)h
(assigned)f(to)g(the)h(tar)o(get)e(list)i(using)f(the)g(standard)f
(rules)h(for)g(assignments,)g(and)g(then)g(the)g(suite)h(is)0
3945 y(e)o(x)o(ecuted.)34 b(When)24 b(the)g(items)g(are)g(e)o(xhausted)
e(\(which)h(is)i(immediately)e(when)g(the)h(sequence)e(is)j(empty\),)f
(the)g(suite)g(in)g(the)g Fo(else)0 4045 y Ft(clause,)c(if)g(present,)g
(is)h(e)o(x)o(ecuted,)d(and)i(the)g(loop)f(terminates.)0
4192 y(A)31 b Fo(break)g Ft(statement)f(e)o(x)o(ecuted)f(in)i(the)g
(\002rst)g(suite)g(terminates)f(the)h(loop)f(without)g(e)o(x)o(ecuting)
f(the)h Fo(else)h Ft(clause')-5 b(s)31 b(suite.)57 b(A)0
4291 y Fo(continue)18 b Ft(statement)g(e)o(x)o(ecuted)f(in)i(the)f
(\002rst)i(suite)f(skips)g(the)f(rest)h(of)g(the)f(suite)i(and)e
(continues)f(with)i(the)g(ne)o(xt)e(item,)i(or)g(with)g(the)0
4391 y Fo(else)h Ft(clause)g(if)h(there)e(w)o(as)i(no)f(ne)o(xt)g
(item.)0 4538 y(The)g(suite)g(may)g(assign)g(to)h(the)f(v)n
(ariable\(s\))f(in)h(the)g(tar)o(get)g(list;)h(this)g(does)f(not)f(af)n
(fect)h(the)g(ne)o(xt)g(item)g(assigned)g(to)g(it.)0
4685 y(The)i(tar)o(get)g(list)h(is)h(not)e(deleted)g(when)f(the)i(loop)
f(is)h(\002nished,)f(b)n(ut)h(if)g(the)f(sequence)f(is)j(empty)-5
b(,)21 b(it)i(will)h(not)e(ha)n(v)o(e)g(been)f(assigned)h(to)0
4784 y(at)e(all)h(by)e(the)h(loop.)k(Hint:)h(the)20 b(b)n(uilt-in)f
(function)f Fo(range\(\))h Ft(returns)g(a)i(sequence)d(of)i(inte)o
(gers)f(suitable)h(to)f(emulate)h(the)g(ef)n(fect)f(of)0
4884 y(P)o(ascal')-5 b(s)21 b Fo(for)49 b(i)h(:=)f(a)h(to)f(b)h(do)p
Ft(;)20 b(e.g.,)g Fo(range\(3\))f Ft(returns)g(the)i(list)g
Fo([0,)49 b(1,)h(2])p Ft(.)0 5031 y Fr(W)-5 b(ar)o(ning:)44
b Ft(There)30 b(is)h(a)f(subtlety)g(when)g(the)g(sequence)f(is)i(being)
e(modi\002ed)g(by)h(the)g(loop)g(\(this)g(can)g(only)g(occur)f(for)h
(mutable)0 5130 y(sequences,)21 b(i.e.)29 b(lists\).)i(An)21
b(internal)g(counter)f(is)j(used)e(to)h(k)o(eep)f(track)g(of)h(which)f
(item)h(is)g(used)g(ne)o(xt,)f(and)g(this)h(is)g(incremented)e(on)0
5230 y(each)j(iteration.)34 b(When)23 b(this)h(counter)e(has)i(reached)
e(the)h(length)g(of)g(the)g(sequence)g(the)g(loop)g(terminates.)34
b(This)23 b(means)g(that)h(if)g(the)0 5330 y(suite)e(deletes)h(the)f
(current)f(\(or)g(a)h(pre)n(vious\))f(item)h(from)f(the)h(sequence,)f
(the)h(ne)o(xt)g(item)g(will)h(be)f(skipped)f(\(since)g(it)i(gets)g
(the)f(inde)o(x)p 0 5549 3901 4 v 0 5649 a Fp(64)2534
b(Chapter)23 b(7.)52 b(Compound)24 b(statements)p eop
end
%%Page: 65 71
TeXDict begin 65 70 bop 0 83 a Ft(of)24 b(the)f(current)g(item)h(which)
f(has)h(already)f(been)g(treated\).)35 b(Lik)o(e)n(wise,)24
b(if)g(the)g(suite)g(inserts)g(an)g(item)g(in)g(the)g(sequence)e
(before)h(the)0 183 y(current)18 b(item,)i(the)f(current)f(item)i(will)
g(be)f(treated)g(again)f(the)i(ne)o(xt)e(time)i(through)d(the)j(loop.)j
(This)d(can)f(lead)g(to)h(nasty)f(b)n(ugs)g(that)h(can)0
282 y(be)g(a)n(v)n(oided)f(by)h(making)f(a)i(temporary)d(cop)o(y)h
(using)h(a)g(slice)h(of)f(the)g(whole)g(sequence,)f(e.g.,)236
429 y Fi(for)45 b(x)f(in)h(a[:]:)416 520 y(if)f(x)h(<)f(0:)h
(a.remove\(x\))0 967 y Fm(7.4)121 b(The)34 b Fa(try)e
Fm(statement)0 1200 y Ft(The)20 b Fo(try)g Ft(statement)g(speci\002es)h
(e)o(xception)d(handlers)h(and/or)g(cleanup)g(code)g(for)h(a)h(group)d
(of)i(statements:)216 1344 y Fo(try_stmt)148 b Ft(::=)99
b Fo(try1_stmt)49 b(|)g(try2_stmt)216 1443 y(try1_stmt)98
b Ft(::=)h Fo("try")49 b(":")h(suite)956 1543 y(\("except")f
([expression)e([",")i(target]])g(":")g(suite\)+)956 1642
y(["else")g(":")g(suite])956 1742 y(["finally")f(":")i(suite])216
1842 y(try2_stmt)98 b Ft(::=)h Fo("try")49 b(":")h(suite)956
1941 y("finally")f(":")g(suite)0 2083 y Ft(Changed)16
b(in)i(v)o(ersion)e(2.5:)i(In)f(pre)n(vious)f(v)o(ersions)h(of)g
(Python,)g Fo(try)p Ft(...)p Fo(except)p Ft(...)p Fo(finally)c
Ft(did)18 b(not)f(w)o(ork.)23 b Fo(try)p Ft(...)p Fo(except)16
b Ft(had)0 2183 y(to)k(be)g(nested)g(in)h Fo(try)p Ft(...)p
Fo(finally)p Ft(.)0 2330 y(The)28 b Fo(except)f Ft(clause\(s\))h
(specify)f(one)g(or)h(more)f(e)o(xception)f(handlers.)47
b(When)28 b(no)g(e)o(xception)e(occurs)h(in)h(the)g Fo(try)g
Ft(clause,)i(no)0 2429 y(e)o(xception)16 b(handler)h(is)i(e)o(x)o
(ecuted.)j(When)c(an)g(e)o(xception)e(occurs)i(in)g(the)g
Fo(try)g Ft(suite,)h(a)f(search)g(for)f(an)h(e)o(xception)e(handler)h
(is)i(started.)0 2529 y(This)f(search)f(inspects)h(the)f(e)o(xcept)g
(clauses)h(in)f(turn)g(until)h(one)f(is)h(found)e(that)i(matches)f(the)
h(e)o(xception.)k(An)17 b(e)o(xpression-less)g(e)o(xcept)0
2629 y(clause,)23 b(if)g(present,)f(must)h(be)f(last;)j(it)f(matches)e
(an)o(y)g(e)o(xception.)30 b(F)o(or)22 b(an)h(e)o(xcept)e(clause)i
(with)g(an)f(e)o(xpression,)g(that)h(e)o(xpression)e(is)0
2728 y(e)n(v)n(aluated,)g(and)h(the)h(clause)f(matches)g(the)h(e)o
(xception)e(if)h(the)h(resulting)e(object)h(is)i(\223compatible\224)d
(with)h(the)h(e)o(xception.)30 b(An)22 b(object)0 2828
y(is)28 b(compatible)d(with)i(an)g(e)o(xception)d(if)k(it)f(is)h(the)f
(class)g(or)g(a)g(base)g(class)h(of)e(the)h(e)o(xception)e(object,)i(a)
g(tuple)g(containing)e(an)h(item)0 2928 y(compatible)18
b(with)j(the)f(e)o(xception,)d(or)m(,)i(in)i(the)f(\(deprecated\))d
(case)j(of)g(string)g(e)o(xceptions,)e(is)j(the)f(raised)f(string)h
(itself)g(\(note)g(that)g(the)0 3027 y(object)g(identities)g(must)g
(match,)f(i.e.)26 b(it)21 b(must)f(be)g(the)g(same)h(string)e(object,)h
(not)g(just)g(a)h(string)f(with)g(the)g(same)h(v)n(alue\).)0
3174 y(If)h(no)f(e)o(xcept)g(clause)g(matches)h(the)f(e)o(xception,)f
(the)i(search)g(for)f(an)g(e)o(xception)f(handler)g(continues)h(in)h
(the)g(surrounding)c(code)j(and)0 3274 y(on)f(the)g(in)m(v)n(ocation)e
(stack.)809 3244 y Fg(1)0 3421 y Ft(If)f(the)h(e)n(v)n(aluation)d(of)j
(an)f(e)o(xpression)f(in)h(the)h(header)e(of)h(an)h(e)o(xcept)e(clause)
h(raises)h(an)g(e)o(xception,)e(the)h(original)f(search)h(for)g(a)h
(handler)0 3520 y(is)25 b(canceled)e(and)g(a)h(search)f(starts)i(for)e
(the)h(ne)n(w)g(e)o(xception)d(in)j(the)g(surrounding)d(code)i(and)g
(on)h(the)f(call)i(stack)f(\(it)g(is)g(treated)g(as)g(if)0
3620 y(the)c(entire)g Fo(try)g Ft(statement)g(raised)g(the)g(e)o
(xception\).)0 3767 y(When)29 b(a)g(matching)f(e)o(xcept)g(clause)h(is)
h(found,)f(the)g(e)o(xception)e(is)j(assigned)f(to)g(the)g(tar)o(get)f
(speci\002ed)h(in)g(that)g(e)o(xcept)f(clause,)j(if)0
3866 y(present,)25 b(and)f(the)h(e)o(xcept)e(clause')-5
b(s)25 b(suite)g(is)h(e)o(x)o(ecuted.)36 b(All)25 b(e)o(xcept)f
(clauses)h(must)g(ha)n(v)o(e)f(an)g(e)o(x)o(ecutable)f(block.)37
b(When)24 b(the)h(end)0 3966 y(of)g(this)h(block)e(is)i(reached,)f(e)o
(x)o(ecution)e(continues)i(normally)e(after)i(the)g(entire)g(try)g
(statement.)40 b(\(This)25 b(means)g(that)h(if)f(tw)o(o)h(nested)0
4066 y(handlers)18 b(e)o(xist)i(for)e(the)i(same)f(e)o(xception,)e(and)
i(the)h(e)o(xception)d(occurs)i(in)g(the)g(try)h(clause)f(of)g(the)g
(inner)g(handler)m(,)e(the)j(outer)e(handler)0 4165 y(will)j(not)f
(handle)f(the)h(e)o(xception.\))0 4312 y(Before)29 b(an)g(e)o(xcept)f
(clause')-5 b(s)29 b(suite)h(is)g(e)o(x)o(ecuted,)f(details)h(about)e
(the)h(e)o(xception)e(are)i(assigned)g(to)g(three)g(v)n(ariables)f(in)h
(the)h Fo(sys)0 4412 y Ft(module:)d Fo(sys.exc_type)20
b Ft(recei)n(v)o(es)h(the)h(object)f(identifying)e(the)j(e)o(xception;)
f Fo(sys.exc_value)e Ft(recei)n(v)o(es)i(the)h(e)o(xception')-5
b(s)0 4511 y(parameter;)19 b Fo(sys.exc_traceback)e Ft(recei)n(v)o(es)i
(a)i(traceback)d(object)i(\(see)g(section)g(3.2\))e(identifying)g(the)i
(point)g(in)g(the)g(program)0 4611 y(where)32 b(the)g(e)o(xception)e
(occurred.)60 b(These)32 b(details)g(are)h(also)f(a)n(v)n(ailable)g
(through)e(the)i Fo(sys.exc_info\(\))f Ft(function,)i(which)0
4711 y(returns)21 b(a)h(tuple)f Fo(\()p Fq(e)n(xc)p 664
4711 25 4 v 29 w(type)p Fo(,)49 b Fq(e)n(xc)p 1040 4711
V 30 w(value)p Fo(,)f Fq(e)n(xc)p 1458 4711 V 30 w(tr)o(acebac)n(k)q
Fo(\))p Ft(.)28 b(Use)23 b(of)e(the)g(corresponding)d(v)n(ariables)j
(is)h(deprecated)e(in)i(f)o(a)n(v)n(or)f(of)0 4810 y(this)28
b(function,)f(since)h(their)f(use)g(is)i(unsafe)d(in)i(a)g(threaded)e
(program.)44 b(As)28 b(of)f(Python)f(1.5,)j(the)e(v)n(ariables)g(are)g
(restored)f(to)i(their)0 4910 y(pre)n(vious)19 b(v)n(alues)g(\(before)g
(the)h(call\))g(when)g(returning)e(from)h(a)i(function)d(that)j
(handled)d(an)i(e)o(xception.)0 5057 y(The)26 b(optional)e
Fo(else)i Ft(clause)g(is)h(e)o(x)o(ecuted)d(if)j(and)e(when)h(control)e
(\003o)n(ws)j(of)n(f)e(the)h(end)f(of)h(the)g Fo(try)g
Ft(clause.)3236 5027 y Fg(2)3312 5057 y Ft(Exceptions)e(in)j(the)0
5156 y Fo(else)20 b Ft(clause)g(are)g(not)g(handled)f(by)h(the)g
(preceding)e Fo(except)i Ft(clauses.)p 0 5227 1560 4
v 90 5283 a Ff(1)120 5306 y Fl(The)c(e)o(xception)k(is)d(propogated)i
(to)f(the)f(in)m(v)o(ocation)j(stack)e(only)g(if)f(there)i(is)e(no)g
Fb(finally)e Fl(clause)k(that)f(ne)o(gates)g(the)g(e)o(xception.)90
5364 y Ff(2)120 5388 y Fl(Currently)l(,)g(control)h(\223\003o)n(ws)e
(of)n(f)h(the)f(end\224)h(e)o(xcept)h(in)f(the)f(case)h(of)f(an)g(e)o
(xception)j(or)d(the)h(e)o(x)o(ecution)i(of)d(a)g Fb(return)p
Fl(,)e Fb(continue)p Fl(,)g(or)i Fb(break)f Fl(statement.)p
0 5549 3901 4 v 0 5649 a Fp(7.4.)52 b(The)23 b Fo(try)g
Fp(statement)2915 b(65)p eop end
%%Page: 66 72
TeXDict begin 66 71 bop 0 83 a Ft(If)29 b Fo(finally)f
Ft(is)i(present,)g(it)f(speci\002es)h(a)f(`cleanup')e(handler)-5
b(.)50 b(The)28 b Fo(try)h Ft(clause)g(is)h(e)o(x)o(ecuted,)f
(including)e(an)o(y)h Fo(except)g Ft(and)0 183 y Fo(else)e
Ft(clauses.)45 b(If)27 b(an)f(e)o(xception)f(occurs)h(in)h(an)o(y)f(of)
g(the)h(clauses)g(and)f(is)i(not)e(handled,)g(the)h(e)o(xception)e(is)i
(temporarily)e(sa)n(v)o(ed.)0 282 y(The)e Fo(finally)g
Ft(clause)g(is)i(e)o(x)o(ecuted.)33 b(If)23 b(there)g(is)h(a)g(sa)n(v)o
(ed)f(e)o(xception,)f(it)j(is)f(re-raised)e(at)i(the)g(end)f(of)g(the)g
Fo(finally)g Ft(clause.)35 b(If)0 382 y(the)19 b Fo(finally)f
Ft(clause)h(raises)h(another)d(e)o(xception)g(or)i(e)o(x)o(ecutes)f(a)h
Fo(return)g Ft(or)f Fo(break)h Ft(statement,)g(the)g(sa)n(v)o(ed)f(e)o
(xception)f(is)j(lost.)0 482 y(The)g(e)o(xception)e(information)g(is)j
(not)f(a)n(v)n(ailable)g(to)g(the)g(program)e(during)h(e)o(x)o(ecution)
f(of)i(the)g Fo(finally)f Ft(clause.)0 628 y(When)j(a)g
Fo(return)p Ft(,)g Fo(break)f Ft(or)h Fo(continue)f Ft(statement)h(is)g
(e)o(x)o(ecuted)e(in)j(the)f Fo(try)f Ft(suite)i(of)e(a)i
Fo(try)p Ft(...)p Fo(finally)d Ft(statement,)i(the)0
728 y Fo(finally)f Ft(clause)i(is)g(also)f(e)o(x)o(ecuted)e(`on)i(the)g
(w)o(ay)g(out.)-6 b(')30 b(A)23 b Fo(continue)e Ft(statement)h(is)h
(ille)o(gal)f(in)g(the)g Fo(finally)f Ft(clause.)31 b(\(The)0
828 y(reason)19 b(is)j(a)e(problem)f(with)h(the)g(current)f
(implementation)f(\227)j(this)g(restriction)e(may)h(be)g(lifted)g(in)g
(the)g(future\).)0 975 y(Additional)h(information)g(on)h(e)o(xceptions)
f(can)i(be)f(found)f(in)i(section)g(4.2,)f(and)g(information)e(on)j
(using)f(the)h Fo(raise)f Ft(statement)g(to)0 1074 y(generate)d(e)o
(xceptions)g(may)g(be)h(found)f(in)h(section)g(6.9.)0
1402 y Fm(7.5)121 b(The)34 b Fa(with)e Fm(statement)0
1634 y Ft(Ne)n(w)20 b(in)h(v)o(ersion)e(2.5.)0 1781 y(The)25
b Fo(with)g Ft(statement)g(is)h(used)e(to)i(wrap)e(the)i(e)o(x)o
(ecution)c(of)j(a)h(block)e(with)h(methods)f(de\002ned)g(by)h(a)h
(conte)o(xt)d(manager)h(\(see)h(sec-)0 1881 y(tion)20
b(3.4.9\).)j(This)d(allo)n(ws)h(common)d Fo(try)p Ft(...)p
Fo(except)p Ft(...)p Fo(finally)f Ft(usage)i(patterns)h(to)g(be)g
(encapsulated)f(for)h(con)m(v)o(enient)d(reuse.)216 2027
y Fo(with_stmt)98 b Ft(::=)h Fo("with")49 b(expression)f(["as")h
(target])f(":")i(suite)0 2175 y Ft(The)20 b(e)o(x)o(ecution)e(of)i(the)
g Fo(with)g Ft(statement)g(proceeds)f(as)i(follo)n(ws:)104
2405 y(1.)41 b(The)19 b(conte)o(xt)g(e)o(xpression)g(is)i(e)n(v)n
(aluated)e(to)h(obtain)f(a)i(conte)o(xt)e(manager)-5
b(.)104 2571 y(2.)41 b(The)19 b(conte)o(xt)g(manager')-5
b(s)19 b Fo(__enter__\(\))g Ft(method)g(is)i(in)m(v)n(ok)o(ed.)104
2737 y(3.)41 b(If)20 b(a)g(tar)o(get)g(w)o(as)h(included)d(in)j(the)f
Fo(with)g Ft(statement,)g(the)g(return)f(v)n(alue)g(from)g
Fo(__enter__\(\))g Ft(is)i(assigned)f(to)g(it.)208 2869
y Fr(Note:)33 b Ft(The)24 b Fo(with)h Ft(statement)f(guarantees)g(that)
g(if)h(the)g Fo(__enter__\(\))e Ft(method)h(returns)g(without)g(an)g
(error)m(,)g(then)h Fo(__-)208 2969 y(exit__\(\))g Ft(will)h(al)o(w)o
(ays)h(be)f(called.)42 b(Thus,)26 b(if)h(an)e(error)g(occurs)h(during)e
(the)i(assignment)f(to)h(the)g(tar)o(get)f(list,)j(it)f(will)g(be)208
3069 y(treated)19 b(the)h(same)h(as)g(an)f(error)f(occurring)f(within)i
(the)g(suite)h(w)o(ould)e(be.)25 b(See)c(step)f(5)g(belo)n(w)-5
b(.)104 3235 y(4.)41 b(The)19 b(suite)i(is)g(e)o(x)o(ecuted.)104
3401 y(5.)41 b(The)19 b(conte)o(xt)f(manager')-5 b(s)18
b Fo(__exit__\(\))h Ft(method)f(is)i(in)m(v)n(ok)o(ed.)j(If)c(an)h(e)o
(xception)e(caused)h(the)g(suite)h(to)g(be)f(e)o(xited,)g(its)h(type,)
208 3500 y(v)n(alue,)d(and)g(traceback)f(are)h(passed)h(as)g(ar)o
(guments)d(to)j Fo(__exit__\(\))p Ft(.)23 b(Otherwise,)18
b(three)f Fo(None)g Ft(ar)o(guments)e(are)j(supplied.)208
3633 y(If)j(the)h(suite)h(w)o(as)g(e)o(xited)e(due)g(to)i(an)f(e)o
(xception,)e(and)h(the)h(return)f(v)n(alue)h(from)f(the)h
Fo(__exit__\(\))e Ft(method)h(w)o(as)i(f)o(alse,)g(the)208
3733 y(e)o(xception)17 b(is)k(reraised.)j(If)c(the)f(return)g(v)n(alue)
g(w)o(as)i(true,)e(the)h(e)o(xception)d(is)k(suppressed,)d(and)i(e)o(x)
o(ecution)d(continues)i(with)h(the)208 3832 y(statement)g(follo)n(wing)
e(the)i Fo(with)g Ft(statement.)208 3965 y(If)i(the)g(suite)h(w)o(as)h
(e)o(xited)d(for)h(an)o(y)g(reason)g(other)f(than)h(an)h(e)o(xception,)
e(the)h(return)g(v)n(alue)g(from)f Fo(__exit__\(\))g
Ft(is)j(ignored,)208 4065 y(and)19 b(e)o(x)o(ecution)f(proceeds)h(at)i
(the)f(normal)f(location)g(for)h(the)g(kind)f(of)h(e)o(xit)g(that)h(w)o
(as)g(tak)o(en.)0 4295 y Fr(Note:)27 b Ft(In)21 b(Python)f(2.5,)h(the)h
Fo(with)f Ft(statement)g(is)i(only)d(allo)n(wed)h(when)g(the)g
Fo(with_statement)f Ft(feature)g(has)i(been)f(enabled.)27
b(It)0 4394 y(will)21 b(al)o(w)o(ays)g(be)f(enabled)f(in)h(Python)f
(2.6.)24 b(This)d Fo(__future__)e Ft(import)g(statement)h(can)g(be)g
(used)g(to)g(enable)g(the)g(feature:)236 4633 y Fi(from)44
b(__future__)g(import)f(with_statement)0 4962 y Fr(See)21
b(Also:)0 5109 y Ft(PEP)g(0343,)d(\223)p Fq(The)j(\224with\224)g
(statement)p Ft(\224)208 5209 y(The)e(speci\002cation,)h(background,)c
(and)k(e)o(xamples)f(for)g(the)i(Python)e Fo(with)h Ft(statement.)p
0 5549 3901 4 v 0 5649 a Fp(66)2534 b(Chapter)23 b(7.)52
b(Compound)24 b(statements)p eop end
%%Page: 67 73
TeXDict begin 67 72 bop 0 87 a Fm(7.6)121 b(Function)34
b(de\002nitions)0 320 y Ft(A)21 b(function)d(de\002nition)h(de\002nes)h
(a)h(user)n(-de\002ned)d(function)h(object)g(\(see)i(section)f(3.2\):)
216 463 y Fo(funcdef)447 b Ft(::=)99 b Fo([decorators])48
b("def")h(funcname)f("\(")h([parameter_list])e("\)")j(":")f(suite)216
563 y(decorators)297 b Ft(::=)99 b Fo(decorator+)216
663 y(decorator)347 b Ft(::=)99 b Fo("@")50 b(dotted_name)d(["\(")j
([argument_list)d([","]])h("\)"])i(NEWLINE)216 762 y(dotted_name)247
b Ft(::=)99 b Fo(identifier)48 b(\(".")h(identifier\))2552
777 y(*)216 862 y(parameter_list)97 b Ft(::=)i Fo(\(defparameter)48
b(","\))2103 877 y(*)1205 962 y(\()100 b(")1405 977 y(*)1455
962 y(")49 b(identifier)f([,)i(")2302 977 y(**)2402 962
y(")f(identifier])1255 1061 y(|)h(")1405 1076 y(**)1505
1061 y(")f(identifier)1255 1161 y(|)h(defparameter)d([","])i(\))216
1260 y(defparameter)197 b Ft(::=)99 b Fo(parameter)49
b(["=")g(expression])216 1360 y(sublist)447 b Ft(::=)99
b Fo(parameter)49 b(\(",")g(parameter\))2453 1375 y(*)2550
1360 y([","])216 1460 y(parameter)347 b Ft(::=)99 b Fo(identifier)48
b(|)i("\(")f(sublist)g("\)")216 1559 y(funcname)397 b
Ft(::=)99 b Fo(identifier)0 1744 y Ft(A)20 b(function)e(de\002nition)h
(is)i(an)f(e)o(x)o(ecutable)e(statement.)24 b(Its)d(e)o(x)o(ecution)c
(binds)j(the)f(function)f(name)i(in)g(the)f(current)g(local)h
(namespace)0 1844 y(to)g(a)g(function)e(object)h(\(a)g(wrapper)g
(around)e(the)j(e)o(x)o(ecutable)e(code)g(for)h(the)h(function\).)j
(This)c(function)f(object)h(contains)g(a)h(reference)0
1944 y(to)g(the)h(current)d(global)i(namespace)f(as)i(the)f(global)f
(namespace)g(to)h(be)h(used)f(when)f(the)h(function)f(is)i(called.)0
2090 y(The)f(function)e(de\002nition)h(does)h(not)g(e)o(x)o(ecute)f
(the)h(function)f(body;)g(this)h(gets)h(e)o(x)o(ecuted)d(only)h(when)h
(the)g(function)f(is)i(called.)0 2237 y(A)28 b(function)e(de\002nition)
g(may)h(be)h(wrapped)e(by)h(one)g(or)g(more)g(decorator)f(e)o
(xpressions.)45 b(Decorator)26 b(e)o(xpressions)h(are)g(e)n(v)n
(aluated)0 2337 y(when)c(the)h(function)e(is)j(de\002ned,)e(in)h(the)g
(scope)f(that)h(contains)f(the)h(function)e(de\002nition.)34
b(The)24 b(result)f(must)h(be)g(a)g(callable,)g(which)0
2437 y(is)e(in)m(v)n(ok)o(ed)c(with)j(the)g(function)e(object)h(as)h
(the)g(only)f(ar)o(gument.)k(The)c(returned)f(v)n(alue)h(is)h(bound)e
(to)i(the)g(function)d(name)i(instead)h(of)0 2536 y(the)f(function)f
(object.)24 b(Multiple)c(decorators)e(are)i(applied)g(in)g(nested)g(f)o
(ashion.)k(F)o(or)c(e)o(xample,)e(the)j(follo)n(wing)d(code:)236
2774 y Fi(@f1\(arg\))236 2866 y(@f2)236 2957 y(def)45
b(func\(\):)e(pass)0 3244 y Ft(is)21 b(equi)n(v)n(alent)e(to:)236
3482 y Fi(def)45 b(func\(\):)e(pass)236 3573 y(func)h(=)h
(f1\(arg\)\(f2\(func\)\))0 3860 y Ft(When)24 b(one)g(or)g(more)g
(top-le)n(v)o(el)e(parameters)h(ha)n(v)o(e)h(the)h(form)e
Fq(par)o(ameter)i Fo(=)g Fq(e)n(xpr)m(ession)p Ft(,)g(the)g(function)d
(is)j(said)g(to)g(ha)n(v)o(e)e(\223def)o(ault)0 3959
y(parameter)f(v)n(alues.)-6 b(\224)34 b(F)o(or)23 b(a)h(parameter)e
(with)h(a)h(def)o(ault)f(v)n(alue,)g(the)g(corresponding)d(ar)o(gument)
h(may)i(be)g(omitted)g(from)f(a)i(call,)g(in)0 4059 y(which)h(case)g
(the)h(parameter')-5 b(s)24 b(def)o(ault)g(v)n(alue)h(is)h
(substituted.)39 b(If)25 b(a)h(parameter)d(has)j(a)f(def)o(ault)g(v)n
(alue,)g(all)h(follo)n(wing)e(parameters)0 4158 y(must)c(also)h(ha)n(v)
o(e)e(a)i(def)o(ault)e(v)n(alue)h(\227)h(this)f(is)i(a)e(syntactic)g
(restriction)f(that)i(is)g(not)f(e)o(xpressed)f(by)g(the)i(grammar)-5
b(.)0 4305 y Fr(Default)21 b(parameter)f(v)o(alues)h(ar)o(e)g(e)o(v)o
(aluated)f(when)i(the)f(function)g(de\002nition)h(is)g(executed.)27
b Ft(This)22 b(means)f(that)g(the)g(e)o(xpression)0 4405
y(is)k(e)n(v)n(aluated)d(once,)i(when)f(the)h(function)e(is)j
(de\002ned,)e(and)h(that)g(that)g(same)g(\223pre-computed\224)c(v)n
(alue)j(is)i(used)e(for)h(each)f(call.)36 b(This)0 4505
y(is)26 b(especially)f(important)e(to)i(understand)e(when)i(a)g(def)o
(ault)f(parameter)g(is)i(a)f(mutable)f(object,)i(such)f(as)g(a)h(list)g
(or)f(a)g(dictionary:)33 b(if)0 4604 y(the)24 b(function)e(modi\002es)i
(the)g(object)g(\(e.g.)35 b(by)24 b(appending)d(an)j(item)h(to)f(a)g
(list\),)i(the)e(def)o(ault)f(v)n(alue)h(is)g(in)h(ef)n(fect)e
(modi\002ed.)35 b(This)25 b(is)0 4704 y(generally)18
b(not)h(what)h(w)o(as)g(intended.)j(A)d(w)o(ay)g(around)d(this)j(is)h
(to)e(use)h Fo(None)f Ft(as)i(the)e(def)o(ault,)g(and)g(e)o(xplicitly)f
(test)j(for)e(it)h(in)f(the)h(body)0 4803 y(of)g(the)g(function,)e
(e.g.:)p 0 5549 3901 4 v 0 5649 a Fp(7.6.)52 b(Function)24
b(de\002nitions)2903 b(67)p eop end
%%Page: 68 74
TeXDict begin 68 73 bop 236 174 a Fi(def)45 b
(whats_on_the_telly\(penguin=None\):)416 266 y(if)f(penguin)g(is)g
(None:)595 357 y(penguin)g(=)g([])416 448 y(penguin.append\("property)c
(of)45 b(the)f(zoo"\))416 540 y(return)f(penguin)0 826
y Ft(Function)27 b(call)j(semantics)e(are)h(described)e(in)i(more)f
(detail)h(in)g(section)f(5.3.4.)49 b(A)29 b(function)e(call)j(al)o(w)o
(ays)f(assigns)g(v)n(alues)f(to)h(all)0 926 y(parameters)19
b(mentioned)f(in)i(the)g(parameter)e(list,)j(either)e(from)g(position)g
(ar)o(guments,)f(from)h(k)o(e)o(yw)o(ord)f(ar)o(guments,)g(or)h(from)g
(def)o(ault)0 1025 y(v)n(alues.)25 b(If)20 b(the)g(form)f(\223)674
1040 y Fo(*)724 1025 y(identifier)p Ft(\224)g(is)i(present,)e(it)i(is)g
(initialized)f(to)h(a)f(tuple)g(recei)n(ving)f(an)o(y)g(e)o(xcess)i
(positional)e(parameters,)0 1125 y(def)o(aulting)g(to)h(the)h(empty)e
(tuple.)26 b(If)20 b(the)g(form)g(\223)1425 1140 y Fo(**)1525
1125 y(identifier)p Ft(\224)e(is)k(present,)d(it)i(is)h(initialized)e
(to)g(a)h(ne)n(w)g(dictionary)d(recei)n(ving)0 1225 y(an)o(y)h(e)o
(xcess)i(k)o(e)o(yw)o(ord)d(ar)o(guments,)g(def)o(aulting)g(to)j(a)f
(ne)n(w)g(empty)g(dictionary)-5 b(.)0 1372 y(It)23 b(is)h(also)g
(possible)e(to)i(create)e(anon)o(ymous)e(functions)i(\(functions)f(not)
i(bound)e(to)i(a)h(name\),)e(for)h(immediate)f(use)h(in)g(e)o
(xpressions.)0 1471 y(This)g(uses)h(lambda)d(forms,)i(described)f(in)h
(section)f(5.11.)32 b(Note)23 b(that)g(the)g(lambda)f(form)g(is)i
(merely)e(a)h(shorthand)e(for)h(a)i(simpli\002ed)0 1571
y(function)g(de\002nition;)i(a)g(function)d(de\002ned)i(in)g(a)h(\223)p
Fo(def)p Ft(\224)f(statement)g(can)g(be)g(passed)g(around)e(or)i
(assigned)g(to)h(another)d(name)i(just)0 1670 y(lik)o(e)d(a)g(function)
e(de\002ned)g(by)h(a)h(lambda)f(form.)27 b(The)22 b(\223)p
Fo(def)p Ft(\224)f(form)f(is)j(actually)e(more)f(po)n(werful)g(since)i
(it)g(allo)n(ws)g(the)f(e)o(x)o(ecution)f(of)0 1770 y(multiple)g
(statements.)0 1917 y Fr(Pr)o(ogrammer')m(s)g(note:)29
b Ft(Functions)22 b(are)g(\002rst-class)h(objects.)32
b(A)23 b(\223)p Fo(def)p Ft(\224)f(form)f(e)o(x)o(ecuted)g(inside)h(a)h
(function)e(de\002nition)g(de\002nes)h(a)0 2017 y(local)i(function)f
(that)h(can)g(be)g(returned)e(or)i(passed)g(around.)35
b(Free)25 b(v)n(ariables)e(used)h(in)g(the)g(nested)g(function)f(can)h
(access)g(the)h(local)0 2116 y(v)n(ariables)19 b(of)h(the)h(function)d
(containing)g(the)i(def.)25 b(See)c(section)f(4.1)f(for)h(details.)0
2444 y Fm(7.7)121 b(Class)33 b(de\002nitions)0 2676 y
Ft(A)21 b(class)g(de\002nition)e(de\002nes)h(a)g(class)i(object)d
(\(see)i(section)f(3.2\):)216 2820 y Fo(classdef)247
b Ft(::=)100 b Fo("class")49 b(classname)f([inheritance])f(":")i(suite)
216 2919 y(inheritance)97 b Ft(::=)j Fo("\(")49 b([expression_list])e
("\)")216 3019 y(classname)197 b Ft(::=)100 b Fo(identifier)0
3161 y Ft(A)24 b(class)g(de\002nition)d(is)j(an)f(e)o(x)o(ecutable)e
(statement.)34 b(It)23 b(\002rst)h(e)n(v)n(aluates)e(the)h(inheritance)
f(list,)i(if)g(present.)32 b(Each)23 b(item)g(in)g(the)g(inher)n(-)0
3261 y(itance)g(list)g(should)f(e)n(v)n(aluate)g(to)h(a)g(class)g
(object)g(or)f(class)i(type)e(which)g(allo)n(ws)h(subclassing.)32
b(The)22 b(class')-5 b(s)24 b(suite)g(is)f(then)f(e)o(x)o(ecuted)0
3360 y(in)e(a)h(ne)n(w)f(e)o(x)o(ecution)e(frame)h(\(see)h(section)g
(4.1\),)f(using)h(a)g(ne)n(wly)g(created)f(local)h(namespace)f(and)h
(the)g(original)f(global)g(namespace.)0 3460 y(\(Usually)-5
b(,)18 b(the)i(suite)f(contains)g(only)g(function)e(de\002nitions.\))24
b(When)19 b(the)g(class')-5 b(s)21 b(suite)f(\002nishes)f(e)o(x)o
(ecution,)f(its)i(e)o(x)o(ecution)d(frame)i(is)0 3559
y(discarded)g(b)n(ut)h(its)h(local)g(namespace)e(is)i(sa)n(v)o(ed.)j(A)
d(class)g(object)f(is)h(then)f(created)f(using)h(the)g(inheritance)f
(list)i(for)f(the)g(base)g(classes)0 3659 y(and)g(the)h(sa)n(v)o(ed)g
(local)g(namespace)e(for)i(the)f(attrib)n(ute)h(dictionary)-5
b(.)25 b(The)20 b(class)i(name)e(is)i(bound)d(to)i(this)h(class)f
(object)g(in)g(the)g(original)0 3759 y(local)f(namespace.)0
3906 y Fr(Pr)o(ogrammer')m(s)26 b(note:)40 b Ft(V)-9
b(ariables)27 b(de\002ned)g(in)h(the)f(class)i(de\002nition)e(are)h
(class)g(v)n(ariables;)j(the)o(y)c(are)h(shared)f(by)h(all)g
(instances.)0 4005 y(T)-7 b(o)27 b(de\002ne)g(instance)f(v)n(ariables,)
i(the)o(y)e(must)h(be)g(gi)n(v)o(en)f(a)h(v)n(alue)g(in)g(the)g
Fo(__init__\(\))e Ft(method)h(or)h(in)g(another)f(method.)44
b(Both)0 4105 y(class)33 b(and)e(instance)g(v)n(ariables)g(are)h
(accessible)g(through)e(the)i(notation)e(\223)p Fo(self.name)p
Ft(\224,)j(and)f(an)f(instance)h(v)n(ariable)e(hides)i(a)0
4204 y(class)24 b(v)n(ariable)e(with)h(the)h(same)f(name)f(when)h
(accessed)g(in)g(this)h(w)o(ay)-5 b(.)33 b(Class)25 b(v)n(ariables)d
(with)h(immutable)f(v)n(alues)h(can)g(be)g(used)g(as)0
4304 y(def)o(aults)17 b(for)f(instance)h(v)n(ariables.)23
b(F)o(or)17 b(ne)n(w-style)f(classes,)j(descriptors)d(can)h(be)g(used)g
(to)g(create)g(instance)g(v)n(ariables)f(with)h(dif)n(ferent)0
4404 y(implementation)h(details.)p 0 5549 3901 4 v 0
5649 a Fp(68)2534 b(Chapter)23 b(7.)52 b(Compound)24
b(statements)p eop end
%%Page: 69 75
TeXDict begin 69 74 bop 0 83 3901 9 v 3503 230 a Fp(CHAPTER)3535
427 y Fn(EIGHT)p 0 515 V 1879 978 a Fz(Top-le)-6 b(v)h(el)57
b(components)0 1465 y Ft(The)24 b(Python)f(interpreter)g(can)h(get)g
(its)i(input)d(from)g(a)i(number)e(of)h(sources:)33 b(from)23
b(a)i(script)f(passed)g(to)h(it)g(as)g(standard)e(input)h(or)g(as)0
1565 y(program)d(ar)o(gument,)f(typed)i(in)h(interacti)n(v)o(ely)-5
b(,)21 b(from)h(a)h(module)e(source)h(\002le,)i(etc.)33
b(This)23 b(chapter)f(gi)n(v)o(es)g(the)h(syntax)f(used)g(in)h(these)0
1664 y(cases.)0 1989 y Fm(8.1)121 b(Complete)35 b(Python)f(prog)o(r)o
(ams)0 2222 y Ft(While)20 b(a)f(language)f(speci\002cation)g(need)h
(not)g(prescribe)f(ho)n(w)g(the)i(language)d(interpreter)h(is)i(in)m(v)
n(ok)o(ed,)d(it)j(is)g(useful)f(to)h(ha)n(v)o(e)e(a)i(notion)0
2321 y(of)k(a)h(complete)f(Python)f(program.)36 b(A)26
b(complete)d(Python)h(program)e(is)k(e)o(x)o(ecuted)c(in)j(a)g
(minimally)f(initialized)g(en)m(vironment:)31 b(all)0
2421 y(b)n(uilt-in)21 b(and)f(standard)g(modules)h(are)g(a)n(v)n
(ailable,)f(b)n(ut)i(none)e(ha)n(v)o(e)h(been)f(initialized,)h(e)o
(xcept)f(for)h Fo(sys)g Ft(\(v)n(arious)f(system)h(services\),)0
2520 y Fo(__builtin__)c Ft(\(b)n(uilt-in)g(functions,)g(e)o(xceptions)f
(and)i Fo(None)p Ft(\))f(and)h Fo(__main__)p Ft(.)23
b(The)18 b(latter)g(is)h(used)f(to)g(pro)o(vide)e(the)i(local)g(and)0
2620 y(global)h(namespace)g(for)h(e)o(x)o(ecution)e(of)i(the)g
(complete)f(program.)0 2767 y(The)h(syntax)f(for)h(a)h(complete)e
(Python)g(program)f(is)j(that)f(for)g(\002le)h(input,)e(described)g(in)
h(the)g(ne)o(xt)g(section.)0 2914 y(The)f(interpreter)f(may)h(also)h
(be)f(in)m(v)n(ok)o(ed)f(in)h(interacti)n(v)o(e)f(mode;)h(in)h(this)g
(case,)f(it)h(does)g(not)f(read)g(and)f(e)o(x)o(ecute)h(a)g(complete)g
(program)0 3013 y(b)n(ut)k(reads)f(and)h(e)o(x)o(ecutes)f(one)g
(statement)h(\(possibly)e(compound\))f(at)j(a)h(time.)33
b(The)22 b(initial)i(en)m(vironment)19 b(is)24 b(identical)f(to)g(that)
g(of)f(a)0 3113 y(complete)d(program;)f(each)i(statement)g(is)h(e)o(x)o
(ecuted)d(in)j(the)f(namespace)f(of)h Fo(__main__)p Ft(.)0
3260 y(Under)27 b(U)t Fl(N)t(I)t(X)r Ft(,)i(a)d(complete)g(program)e
(can)i(be)g(passed)g(to)g(the)h(interpreter)d(in)i(three)g(forms:)37
b(with)26 b(the)g Fr(-c)h Fq(string)f Ft(command)e(line)0
3360 y(option,)f(as)i(a)f(\002le)g(passed)g(as)h(the)e(\002rst)i
(command)d(line)i(ar)o(gument,)e(or)h(as)i(standard)d(input.)35
b(If)24 b(the)g(\002le)g(or)g(standard)e(input)h(is)i(a)f(tty)0
3459 y(de)n(vice,)19 b(the)h(interpreter)f(enters)h(interacti)n(v)o(e)f
(mode;)g(otherwise,)g(it)i(e)o(x)o(ecutes)e(the)i(\002le)f(as)h(a)g
(complete)e(program.)0 3784 y Fm(8.2)121 b(File)33 b(input)0
4016 y Ft(All)21 b(input)e(read)h(from)f(non-interacti)n(v)o(e)e
(\002les)k(has)g(the)f(same)g(form:)216 4162 y Fo(file_input)98
b Ft(::=)h Fo(\(NEWLINE)49 b(|)g(statement\))2054 4177
y(*)0 4310 y Ft(This)20 b(syntax)g(is)h(used)f(in)g(the)h(follo)n(wing)
d(situations:)125 4524 y Fs(\017)41 b Ft(when)19 b(parsing)g(a)i
(complete)e(Python)g(program)f(\(from)h(a)i(\002le)f(or)g(from)f(a)i
(string\);)125 4683 y Fs(\017)41 b Ft(when)19 b(parsing)g(a)i(module;)
125 4843 y Fs(\017)41 b Ft(when)19 b(parsing)g(a)i(string)f(passed)g
(to)g(the)g Fo(exec)g Ft(statement;)0 5167 y Fm(8.3)121
b(Inter)o(activ)m(e)34 b(input)0 5400 y Ft(Input)19 b(in)h(interacti)n
(v)o(e)f(mode)g(is)j(parsed)d(using)h(the)g(follo)n(wing)e(grammar:)p
0 5549 3901 4 v 3808 5649 a Fp(69)p eop end
%%Page: 70 76
TeXDict begin 70 75 bop 216 82 a Fo(interactive_input)96
b Ft(::=)k Fo([stmt_list])48 b(NEWLINE)g(|)i(compound_stmt)d(NEWLINE)0
230 y Ft(Note)26 b(that)g(a)g(\(top-le)n(v)o(el\))e(compound)f
(statement)i(must)h(be)g(follo)n(wed)f(by)g(a)h(blank)f(line)h(in)g
(interacti)n(v)o(e)f(mode;)j(this)e(is)h(needed)d(to)0
330 y(help)c(the)g(parser)g(detect)g(the)g(end)f(of)h(the)g(input.)0
657 y Fm(8.4)121 b(Expression)33 b(input)0 890 y Ft(There)19
b(are)h(tw)o(o)g(forms)f(of)g(e)o(xpression)f(input.)25
b(Both)19 b(ignore)g(leading)g(whitespace.)24 b(The)19
b(string)h(ar)o(gument)d(to)j Fo(eval\(\))f Ft(must)h(ha)n(v)o(e)0
989 y(the)g(follo)n(wing)f(form:)216 1135 y Fo(eval_input)98
b Ft(::=)h Fo(expression_list)47 b(NEWLINE)2153 1150
y(*)0 1283 y Ft(The)20 b(input)f(line)i(read)e(by)h Fo(input\(\))f
Ft(must)i(ha)n(v)o(e)e(the)h(follo)n(wing)f(form:)216
1429 y Fo(input_input)97 b Ft(::=)j Fo(expression_list)47
b(NEWLINE)0 1577 y Ft(Note:)58 b(to)37 b(read)f(`ra)o(w')g(input)g
(line)h(without)f(interpretation,)j(you)c(can)i(use)g(the)g(b)n
(uilt-in)f(function)f Fo(raw_input\(\))g Ft(or)i(the)0
1676 y Fo(readline\(\))19 b Ft(method)g(of)h(\002le)g(objects.)p
0 5549 3901 4 v 0 5649 a Fp(70)2567 b(Chapter)23 b(8.)52
b(T)-10 b(op-le)n(v)n(el)23 b(components)p eop end
%%Page: 71 77
TeXDict begin 71 76 bop 0 83 3901 9 v 3480 230 a Fp(APPENDIX)3814
427 y Fn(A)p 0 515 V 2080 978 a Fz(Histor)6 b(y)58 b(and)f(License)0
1506 y Fm(A.1)120 b(Histor)t(y)33 b(of)h(the)g(softw)n(are)0
1739 y Ft(Python)39 b(w)o(as)i(created)f(in)g(the)h(early)e(1990s)h(by)
g(Guido)f(v)n(an)h(Rossum)g(at)h(Stichting)f(Mathematisch)f(Centrum)g
(\(CWI,)i(see)0 1839 y Fu(
http://www)l(.cwi.nl/)l Ft(\))30
b(in)g(the)g(Netherlands)e(as)j(a)f(successor)g(of)f(a)i(language)d
(called)i(ABC.)g(Guido)f(remains)h(Python')-5 b(s)29
b(principal)0 1939 y(author)m(,)18 b(although)h(it)i(includes)e(man)o
(y)g(contrib)n(utions)f(from)h(others.)0 2085 y(In)36
b(1995,)j(Guido)c(continued)f(his)j(w)o(ork)e(on)h(Python)f(at)i(the)f
(Corporation)e(for)i(National)g(Research)g(Initiati)n(v)o(es)f(\(CNRI,)
i(see)0 2185 y Fu(
http://www)l(.cnr)q(i.reston.v)n(a.us/)-6
b Ft(\))21 b(in)f(Reston,)g(V)-5 b(ir)o(ginia)19 b(where)h(he)g
(released)g(se)n(v)o(eral)f(v)o(ersions)g(of)h(the)g(softw)o(are.)0
2332 y(In)h(May)h(2000,)e(Guido)h(and)g(the)h(Python)e(core)h(de)n(v)o
(elopment)e(team)j(mo)o(v)o(ed)d(to)j(BeOpen.com)e(to)i(form)e(the)i
(BeOpen)f(PythonLabs)0 2432 y(team.)49 b(In)27 b(October)g(of)h(the)g
(same)h(year)m(,)g(the)f(PythonLabs)e(team)i(mo)o(v)o(ed)e(to)i
(Digital)h(Creations)f(\(no)n(w)f(Zope)g(Corporation;)j(see)0
2531 y Fu(
http://www)l(.z)o(ope)o(.com/)l Ft(\).)g(In)21
b(2001,)g(the)h(Python)f(Softw)o(are)g(F)o(oundation)f(\(PSF)-7
b(,)22 b(see)h Fu(
http://www)l(.p)n(ython.org/)o(psf/)-6
b Ft(\))22 b(w)o(as)h(formed,)d(a)0 2631 y(non-pro\002t)h(or)o
(ganization)f(created)i(speci\002cally)h(to)g(o)n(wn)g(Python-related)d
(Intellectual)j(Property)-5 b(.)32 b(Zope)22 b(Corporation)f(is)j(a)g
(spon-)0 2730 y(soring)19 b(member)g(of)h(the)g(PSF)-7
b(.)0 2877 y(All)26 b(Python)d(releases)j(are)e(Open)h(Source)f(\(see)h
Fu(
http://www)l(.opensource)o(.o)o(rg/)19 b Ft(for)24
b(the)h(Open)g(Source)f(De\002nition\).)38 b(Historically)-5
b(,)0 2977 y(most,)20 b(b)n(ut)g(not)g(all,)h(Python)e(releases)h(ha)n
(v)o(e)g(also)g(been)g(GPL-compatible;)e(the)i(table)g(belo)n(w)g
(summarizes)f(the)h(v)n(arious)g(releases.)p 0 5549 3901
4 v 3808 5649 a Fp(71)p eop end
%%Page: 72 78
TeXDict begin 72 77 bop 670 70 a Fr(Release)p 1074 100
4 100 v 188 w(Deri)o(v)o(ed)20 b(fr)o(om)p 1648 100 V
195 w(Y)-9 b(ear)p 2107 100 V 291 w(Owner)p 2643 100
V 195 w(GPL)21 b(compatible?)p 531 103 2838 4 v 581 173
a Ft(0.9.0)e(thru)g(1.2)p 1074 203 4 100 v 285 w(n/a)p
1648 203 V 285 w(1991-1995)p 2107 203 V 233 w(CWI)p 2643
203 V 494 w(yes)581 272 y(1.3)g(thru)h(1.5.2)p 1074 302
V 283 w(1.2)p 1648 302 V 283 w(1995-1999)p 2107 302 V
214 w(CNRI)p 2643 302 V 476 w(yes)752 372 y(1.6)p 1074
402 V 423 w(1.5.2)p 1648 402 V 348 w(2000)p 2107 402
V 313 w(CNRI)p 2643 402 V 490 w(no)752 472 y(2.0)p 1074
501 V 454 w(1.6)p 1648 501 V 380 w(2000)p 2107 501 V
195 w(BeOpen.com)p 2643 501 V 368 w(no)720 571 y(1.6.1)p
1074 601 V 423 w(1.6)p 1648 601 V 380 w(2001)p 2107 601
V 313 w(CNRI)p 2643 601 V 490 w(no)752 671 y(2.1)p 1074
701 V 347 w(2.0+1.6.1)p 1648 701 V 272 w(2001)p 2107
701 V 343 w(PSF)p 2643 701 V 520 w(no)720 770 y(2.0.1)p
1074 800 V 316 w(2.0+1.6.1)p 1648 800 V 272 w(2001)p
2107 800 V 343 w(PSF)p 2643 800 V 506 w(yes)720 870 y(2.1.1)p
1074 900 V 316 w(2.1+2.0.1)p 1648 900 V 272 w(2001)p
2107 900 V 343 w(PSF)p 2643 900 V 506 w(yes)752 970 y(2.2)p
1074 1000 V 423 w(2.1.1)p 1648 1000 V 348 w(2001)p 2107
1000 V 343 w(PSF)p 2643 1000 V 506 w(yes)720 1069 y(2.1.2)p
1074 1099 V 392 w(2.1.1)p 1648 1099 V 348 w(2002)p 2107
1099 V 343 w(PSF)p 2643 1099 V 506 w(yes)720 1169 y(2.1.3)p
1074 1199 V 392 w(2.1.2)p 1648 1199 V 348 w(2002)p 2107
1199 V 343 w(PSF)p 2643 1199 V 506 w(yes)720 1269 y(2.2.1)p
1074 1298 V 423 w(2.2)p 1648 1298 V 380 w(2002)p 2107
1298 V 343 w(PSF)p 2643 1298 V 506 w(yes)720 1368 y(2.2.2)p
1074 1398 V 392 w(2.2.1)p 1648 1398 V 348 w(2002)p 2107
1398 V 343 w(PSF)p 2643 1398 V 506 w(yes)720 1468 y(2.2.3)p
1074 1498 V 392 w(2.2.2)p 1648 1498 V 251 w(2002-2003)p
2107 1498 V 244 w(PSF)p 2643 1498 V 506 w(yes)752 1567
y(2.3)p 1074 1597 V 423 w(2.2.2)p 1648 1597 V 251 w(2002-2003)p
2107 1597 V 244 w(PSF)p 2643 1597 V 506 w(yes)720 1667
y(2.3.1)p 1074 1697 V 423 w(2.3)p 1648 1697 V 283 w(2002-2003)p
2107 1697 V 244 w(PSF)p 2643 1697 V 506 w(yes)720 1767
y(2.3.2)p 1074 1797 V 392 w(2.3.1)p 1648 1797 V 348 w(2003)p
2107 1797 V 343 w(PSF)p 2643 1797 V 506 w(yes)720 1866
y(2.3.3)p 1074 1896 V 392 w(2.3.2)p 1648 1896 V 348 w(2003)p
2107 1896 V 343 w(PSF)p 2643 1896 V 506 w(yes)720 1966
y(2.3.4)p 1074 1996 V 392 w(2.3.3)p 1648 1996 V 348 w(2004)p
2107 1996 V 343 w(PSF)p 2643 1996 V 506 w(yes)720 2066
y(2.3.5)p 1074 2095 V 392 w(2.3.4)p 1648 2095 V 348 w(2005)p
2107 2095 V 343 w(PSF)p 2643 2095 V 506 w(yes)752 2165
y(2.4)p 1074 2195 V 454 w(2.3)p 1648 2195 V 380 w(2004)p
2107 2195 V 343 w(PSF)p 2643 2195 V 506 w(yes)720 2265
y(2.4.1)p 1074 2295 V 423 w(2.4)p 1648 2295 V 380 w(2005)p
2107 2295 V 343 w(PSF)p 2643 2295 V 506 w(yes)720 2364
y(2.4.2)p 1074 2394 V 392 w(2.4.1)p 1648 2394 V 348 w(2005)p
2107 2394 V 343 w(PSF)p 2643 2394 V 506 w(yes)720 2464
y(2.4.3)p 1074 2494 V 392 w(2.4.2)p 1648 2494 V 348 w(2006)p
2107 2494 V 343 w(PSF)p 2643 2494 V 506 w(yes)720 2564
y(2.4.4)p 1074 2594 V 392 w(2.4.3)p 1648 2594 V 348 w(2006)p
2107 2594 V 343 w(PSF)p 2643 2594 V 506 w(yes)752 2663
y(2.5)p 1074 2693 V 454 w(2.4)p 1648 2693 V 380 w(2006)p
2107 2693 V 343 w(PSF)p 2643 2693 V 506 w(yes)720 2763
y(2.5.1)p 1074 2793 V 423 w(2.5)p 1648 2793 V 380 w(2007)p
2107 2793 V 343 w(PSF)p 2643 2793 V 506 w(yes)720 2863
y(2.5.2)p 1074 2892 V 392 w(2.5.1)p 1648 2892 V 348 w(2008)p
2107 2892 V 343 w(PSF)p 2643 2892 V 506 w(yes)0 3088
y Fr(Note:)35 b Ft(GPL-compatible)24 b(doesn')o(t)g(mean)g(that)i(we')l
(re)f(distrib)n(uting)f(Python)h(under)f(the)h(GPL.)h(All)g(Python)f
(licenses,)i(unlik)o(e)e(the)0 3187 y(GPL,)e(let)g(you)f(distrib)n(ute)
h(a)g(modi\002ed)f(v)o(ersion)f(without)h(making)g(your)f(changes)h
(open)g(source.)32 b(The)22 b(GPL-compatible)f(licenses)0
3287 y(mak)o(e)f(it)h(possible)f(to)g(combine)f(Python)g(with)h(other)f
(softw)o(are)h(that)g(is)i(released)d(under)g(the)h(GPL;)h(the)f
(others)g(don')o(t.)0 3434 y(Thanks)f(to)i(the)f(man)o(y)f(outside)g(v)
n(olunteers)g(who)h(ha)n(v)o(e)g(w)o(ork)o(ed)f(under)f(Guido')-5
b(s)20 b(direction)f(to)h(mak)o(e)g(these)g(releases)h(possible.)0
3761 y Fm(A.2)120 b(T)-14 b(er)s(ms)33 b(and)h(conditions)h(f)l(or)f
(accessing)g(or)f(otherwise)i(using)f(Python)1024 3947
y Fr(PSF)20 b(LICENSE)j(A)-5 b(GREEMENT)22 b(FOR)e(PYTHON)g(2.5.3)104
4094 y Ft(1.)41 b(This)22 b(LICENSE)g(A)m(GREEMENT)f(is)j(between)d
(the)h(Python)f(Softw)o(are)h(F)o(oundation)e(\(\223PSF\224\),)i(and)f
(the)i(Indi)n(vidual)c(or)j(Or)n(-)208 4193 y(ganization)g
(\(\223Licensee\224\))h(accessing)h(and)g(otherwise)f(using)h(Python)f
(2.5.3)g(softw)o(are)h(in)h(source)e(or)h(binary)f(form)h(and)g(its)208
4293 y(associated)c(documentation.)104 4459 y(2.)41 b(Subject)28
b(to)g(the)h(terms)f(and)g(conditions)f(of)h(this)h(License)f
(Agreement,)h(PSF)g(hereby)e(grants)h(Licensee)g(a)h(none)o(xclusi)n(v)
o(e,)208 4559 y(ro)o(yalty-free,)e(w)o(orld-wide)g(license)h(to)g
(reproduce,)f(analyze,)i(test,)i(perform)26 b(and/or)h(display)g
(publicly)-5 b(,)28 b(prepare)f(deri)n(v)n(a-)208 4658
y(ti)n(v)o(e)g(w)o(orks,)h(distrib)n(ute,)h(and)e(otherwise)g(use)h
(Python)e(2.5.3)g(alone)h(or)g(in)h(an)o(y)e(deri)n(v)n(ati)n(v)o(e)g
(v)o(ersion,)i(pro)o(vided,)e(ho)n(we)n(v)o(er)m(,)208
4758 y(that)e(PSF')-5 b(s)26 b(License)e(Agreement)f(and)h(PSF')-5
b(s)25 b(notice)f(of)g(cop)o(yright,)f(i.e.,)j(\223Cop)o(yright)2871
4755 y(c)2848 4758 y Fs(\015)f Ft(2001-2008)c(Python)i(Softw)o(are)208
4857 y(F)o(oundation;)i(All)h(Rights)g(Reserv)o(ed\224)e(are)i
(retained)e(in)h(Python)f(2.5.3)g(alone)h(or)g(in)h(an)o(y)e(deri)n(v)n
(ati)n(v)o(e)g(v)o(ersion)g(prepared)f(by)208 4957 y(Licensee.)104
5123 y(3.)41 b(In)16 b(the)h(e)n(v)o(ent)f(Licensee)h(prepares)e(a)j
(deri)n(v)n(ati)n(v)o(e)d(w)o(ork)h(that)h(is)h(based)e(on)h(or)g
(incorporates)d(Python)i(2.5.3)g(or)g(an)o(y)h(part)f(thereof,)208
5223 y(and)25 b(w)o(ants)h(to)f(mak)o(e)g(the)h(deri)n(v)n(ati)n(v)o(e)
d(w)o(ork)i(a)n(v)n(ailable)g(to)h(others)f(as)h(pro)o(vided)d(herein,)
j(then)f(Licensee)g(hereby)f(agrees)h(to)208 5322 y(include)19
b(in)h(an)o(y)f(such)h(w)o(ork)g(a)h(brief)e(summary)g(of)h(the)g
(changes)f(made)h(to)g(Python)f(2.5.3.)p 0 5549 3901
4 v 0 5649 a Fp(72)2583 b(Appendix)24 b(A.)47 b(Histor)r(y)22
b(and)i(License)p eop end
%%Page: 73 79
TeXDict begin 73 78 bop 104 83 a Ft(4.)41 b(PSF)30 b(is)g(making)e
(Python)h(2.5.3)f(a)n(v)n(ailable)h(to)g(Licensee)g(on)g(an)g(\223)-7
b(AS)31 b(IS\224)e(basis.)53 b(PSF)31 b(MAKES)e(NO)h(REPRESENT)-8
b(A-)208 183 y(TIONS)25 b(OR)h(W)-10 b(ARRANTIES,)26
b(EXPRESS)g(OR)g(IMPLIED.)f(BY)h(W)-10 b(A)h(Y)26 b(OF)g(EXAMPLE,)f(B)o
(UT)h(NO)m(T)f(LIMIT)-8 b(A)f(TION,)208 282 y(PSF)26
b(MAKES)f(NO)h(AND)g(DISCLAIMS)f(ANY)h(REPRESENT)-8 b(A)f(TION)25
b(OR)h(W)-10 b(ARRANTY)27 b(OF)f(MERCHANT)-8 b(ABIL-)208
382 y(ITY)17 b(OR)h(FITNESS)f(FOR)i(ANY)e(P)-8 b(AR)j(TICULAR)19
b(PURPOSE)f(OR)g(THA)-9 b(T)17 b(THE)g(USE)h(OF)g(PYTHON)f(2.5.3)f
(WILL)i(NO)m(T)208 482 y(INFRINGE)i(ANY)g(THIRD)h(P)-8
b(AR)j(TY)21 b(RIGHTS.)104 648 y(5.)41 b(PSF)29 b(SHALL)g(NO)m(T)g(BE)g
(LIABLE)g(T)o(O)f(LICENSEE)g(OR)i(ANY)f(O)m(THER)g(USERS)h(OF)f(PYTHON)
g(2.5.3)e(FOR)j(ANY)208 747 y(INCIDENT)-8 b(AL,)18 b(SPECIAL,)h(OR)h
(CONSEQ)o(UENTIAL)f(D)m(AMA)m(GES)f(OR)i(LOSS)g(AS)g(A)g(RESUL)-8
b(T)19 b(OF)h(MODIFYING,)208 847 y(DISTRIB)o(UTING,)j(OR)h(O)m(THER)-5
b(WISE)24 b(USING)g(PYTHON)g(2.5.3,)f(OR)h(ANY)g(DERIV)-11
b(A)i(TIVE)23 b(THEREOF)-7 b(,)24 b(EVEN)f(IF)208 946
y(AD)m(VISED)c(OF)i(THE)f(POSSIBILITY)g(THEREOF)-7 b(.)104
1112 y(6.)41 b(This)20 b(License)g(Agreement)e(will)j(automatically)e
(terminate)g(upon)g(a)i(material)f(breach)f(of)h(its)h(terms)f(and)g
(conditions.)104 1279 y(7.)41 b(Nothing)23 b(in)i(this)g(License)g
(Agreement)e(shall)i(be)g(deemed)e(to)i(create)g(an)o(y)f(relationship)
f(of)i(agenc)o(y)-5 b(,)23 b(partnership,)h(or)h(joint)208
1378 y(v)o(enture)20 b(between)h(PSF)h(and)g(Licensee.)29
b(This)22 b(License)f(Agreement)g(does)g(not)h(grant)f(permission)f(to)
i(use)g(PSF)h(trademarks)208 1478 y(or)c(trade)h(name)g(in)g(a)h
(trademark)d(sense)j(to)f(endorse)f(or)h(promote)e(products)h(or)h
(services)g(of)g(Licensee,)g(or)f(an)o(y)h(third)f(party)-5
b(.)104 1644 y(8.)41 b(By)18 b(cop)o(ying,)e(installing)h(or)h
(otherwise)f(using)g(Python)g(2.5.3,)g(Licensee)g(agrees)g(to)h(be)g
(bound)e(by)h(the)h(terms)g(and)f(conditions)208 1743
y(of)i(this)i(License)f(Agreement.)846 1926 y Fr(BEOPEN.COM)h(LICENSE)h
(A)-5 b(GREEMENT)23 b(FOR)d(PYTHON)g(2.0)579 2026 y(BEOPEN)h(PYTHON)f
(OPEN)g(SOURCE)h(LICENSE)h(A)-5 b(GREEMENT)23 b(VERSION)e(1)104
2256 y Ft(1.)41 b(This)20 b(LICENSE)g(A)m(GREEMENT)f(is)i(between)f
(BeOpen.com)e(\(\223BeOpen\224\),)h(ha)n(ving)g(an)h(of)n(\002ce)g(at)g
(160)g(Saratoga)e(A)-6 b(v)o(enue,)208 2355 y(Santa)29
b(Clara,)i(CA)f(95051,)f(and)f(the)h(Indi)n(vidual)e(or)i(Or)o
(ganization)d(\(\223Licensee\224\))h(accessing)i(and)f(otherwise)h
(using)f(this)208 2455 y(softw)o(are)19 b(in)i(source)e(or)h(binary)f
(form)g(and)h(its)h(associated)f(documentation)d(\(\223the)j(Softw)o
(are\224\).)104 2621 y(2.)41 b(Subject)18 b(to)g(the)h(terms)g(and)f
(conditions)f(of)h(this)h(BeOpen)f(Python)f(License)i(Agreement,)e
(BeOpen)h(hereby)f(grants)h(Licensee)208 2721 y(a)25
b(non-e)o(xclusi)n(v)o(e,)e(ro)o(yalty-free,)h(w)o(orld-wide)f(license)
j(to)f(reproduce,)f(analyze,)h(test,)i(perform)c(and/or)h(display)g
(publicly)-5 b(,)208 2820 y(prepare)16 b(deri)n(v)n(ati)n(v)o(e)f(w)o
(orks,)j(distrib)n(ute,)f(and)g(otherwise)g(use)h(the)g(Softw)o(are)f
(alone)g(or)g(in)h(an)o(y)f(deri)n(v)n(ati)n(v)o(e)f(v)o(ersion,)g(pro)
o(vided,)208 2920 y(ho)n(we)n(v)o(er)m(,)f(that)i(the)g(BeOpen)g
(Python)f(License)i(is)g(retained)e(in)h(the)h(Softw)o(are,)f(alone)f
(or)h(in)h(an)o(y)e(deri)n(v)n(ati)n(v)o(e)g(v)o(ersion)g(prepared)208
3019 y(by)j(Licensee.)104 3185 y(3.)41 b(BeOpen)25 b(is)j(making)c(the)
j(Softw)o(are)e(a)n(v)n(ailable)h(to)g(Licensee)g(on)g(an)g(\223)-7
b(AS)27 b(IS\224)g(basis.)43 b(BEOPEN)27 b(MAKES)f(NO)h(REPRE-)208
3285 y(SENT)-8 b(A)f(TIONS)27 b(OR)i(W)-10 b(ARRANTIES,)29
b(EXPRESS)g(OR)g(IMPLIED.)f(BY)h(W)-10 b(A)h(Y)29 b(OF)g(EXAMPLE,)e(B)o
(UT)i(NO)m(T)g(LIMI-)208 3385 y(T)-8 b(A)f(TION,)20 b(BEOPEN)h(MAKES)f
(NO)i(AND)f(DISCLAIMS)f(ANY)h(REPRESENT)-8 b(A)f(TION)21
b(OR)g(W)-10 b(ARRANTY)22 b(OF)f(MER-)208 3484 y(CHANT)-8
b(ABILITY)21 b(OR)i(FITNESS)e(FOR)i(ANY)f(P)-8 b(AR)j(TICULAR)23
b(PURPOSE)g(OR)f(THA)-9 b(T)21 b(THE)h(USE)g(OF)g(THE)g(SOFT)-8
b(-)208 3584 y(W)e(ARE)21 b(WILL)f(NO)m(T)g(INFRINGE)g(ANY)h(THIRD)f(P)
-8 b(AR)j(TY)21 b(RIGHTS.)104 3750 y(4.)41 b(BEOPEN)24
b(SHALL)f(NO)m(T)h(BE)g(LIABLE)g(T)o(O)f(LICENSEE)g(OR)i(ANY)f(O)m
(THER)f(USERS)i(OF)f(THE)g(SOFTW)-10 b(ARE)25 b(FOR)208
3850 y(ANY)c(INCIDENT)-8 b(AL,)20 b(SPECIAL,)h(OR)h(CONSEQ)o(UENTIAL)e
(D)m(AMA)m(GES)h(OR)h(LOSS)f(AS)h(A)f(RESUL)-8 b(T)22
b(OF)g(USING,)208 3949 y(MODIFYING)j(OR)i(DISTRIB)o(UTING)f(THE)h
(SOFTW)-10 b(ARE,)27 b(OR)g(ANY)f(DERIV)-11 b(A)i(TIVE)25
b(THEREOF)-7 b(,)27 b(EVEN)f(IF)g(AD-)208 4049 y(VISED)20
b(OF)h(THE)f(POSSIBILITY)g(THEREOF)-7 b(.)104 4215 y(5.)41
b(This)20 b(License)g(Agreement)e(will)j(automatically)e(terminate)g
(upon)g(a)i(material)f(breach)f(of)h(its)h(terms)f(and)g(conditions.)
104 4381 y(6.)41 b(This)27 b(License)f(Agreement)g(shall)h(be)g(go)o(v)
o(erned)d(by)j(and)f(interpreted)f(in)j(all)f(respects)g(by)g(the)g(la)
o(w)g(of)g(the)g(State)g(of)g(Cali-)208 4481 y(fornia,)22
b(e)o(xcluding)e(con\003ict)j(of)f(la)o(w)i(pro)o(visions.)31
b(Nothing)21 b(in)j(this)f(License)g(Agreement)e(shall)i(be)g(deemed)f
(to)h(create)f(an)o(y)208 4580 y(relationship)i(of)h(agenc)o(y)-5
b(,)25 b(partnership,)g(or)g(joint)h(v)o(enture)e(between)h(BeOpen)g
(and)g(Licensee.)41 b(This)26 b(License)f(Agreement)208
4680 y(does)18 b(not)h(grant)f(permission)f(to)i(use)h(BeOpen)e
(trademarks)f(or)i(trade)f(names)h(in)g(a)g(trademark)e(sense)i(to)g
(endorse)f(or)g(promote)208 4779 y(products)k(or)h(services)g(of)h
(Licensee,)f(or)h(an)o(y)e(third)h(party)-5 b(.)34 b(As)24
b(an)g(e)o(xception,)e(the)i(\223BeOpen)f(Python\224)f(logos)h(a)n(v)n
(ailable)g(at)208 4879 y(
http://www)-5 b(.p)o(ythonlabs.com/logo)o
(s.htm)o(l)15 b(may)20 b(be)g(used)g(according)e(to)i(the)h
(permissions)e(granted)g(on)h(that)g(web)g(page.)104
5045 y(7.)41 b(By)19 b(cop)o(ying,)e(installing)h(or)g(otherwise)g
(using)h(the)f(softw)o(are,)h(Licensee)f(agrees)g(to)h(be)f(bound)f(by)
i(the)f(terms)h(and)f(conditions)208 5145 y(of)h(this)i(License)f
(Agreement.)992 5327 y Fr(CNRI)h(LICENSE)h(A)-5 b(GREEMENT)22
b(FOR)e(PYTHON)g(1.6.1)p 0 5549 3901 4 v 0 5649 a Fp(A.2.)52
b(T)-10 b(er)r(ms)23 b(and)g(conditions)h(f)n(or)f(accessing)f(or)h
(otherwise)g(using)g(Python)1336 b(73)p eop end
%%Page: 74 80
TeXDict begin 74 79 bop 104 83 a Ft(1.)41 b(This)25 b(LICENSE)g(A)m
(GREEMENT)f(is)i(between)e(the)h(Corporation)e(for)h(National)h
(Research)g(Initiati)n(v)o(es,)g(ha)n(ving)f(an)h(of)n(\002ce)208
183 y(at)j(1895)f(Preston)h(White)h(Dri)n(v)o(e,)g(Reston,)h(V)-11
b(A)29 b(20191)d(\(\223CNRI\224\),)i(and)f(the)i(Indi)n(vidual)d(or)i
(Or)o(ganization)d(\(\223Licensee\224\))208 282 y(accessing)18
b(and)g(otherwise)g(using)g(Python)f(1.6.1)h(softw)o(are)g(in)h(source)
e(or)i(binary)e(form)h(and)g(its)h(associated)g(documentation.)104
443 y(2.)41 b(Subject)24 b(to)g(the)h(terms)f(and)g(conditions)f(of)h
(this)h(License)g(Agreement,)e(CNRI)j(hereby)d(grants)h(Licensee)g(a)h
(none)o(xclusi)n(v)o(e,)208 542 y(ro)o(yalty-free,)18
b(w)o(orld-wide)i(license)h(to)g(reproduce,)d(analyze,)j(test,)g
(perform)e(and/or)h(display)h(publicly)-5 b(,)19 b(prepare)g(deri)n(v)n
(ati)n(v)o(e)208 642 y(w)o(orks,)28 b(distrib)n(ute,)g(and)f(otherwise)
f(use)i(Python)e(1.6.1)f(alone)i(or)g(in)g(an)o(y)f(deri)n(v)n(ati)n(v)
o(e)g(v)o(ersion,)h(pro)o(vided,)f(ho)n(we)n(v)o(er)m(,)g(that)208
741 y(CNRI')-5 b(s)30 b(License)f(Agreement)f(and)g(CNRI')-5
b(s)31 b(notice)e(of)g(cop)o(yright,)g(i.e.,)i(\223Cop)o(yright)2893
738 y(c)2870 741 y Fs(\015)f Ft(1995-2001)25 b(Corporation)i(for)208
841 y(National)k(Research)h(Initiati)n(v)o(es;)37 b(All)32
b(Rights)g(Reserv)o(ed\224)f(are)h(retained)f(in)h(Python)e(1.6.1)h
(alone)g(or)g(in)h(an)o(y)f(deri)n(v)n(ati)n(v)o(e)208
941 y(v)o(ersion)22 b(prepared)g(by)h(Licensee.)35 b(Alternately)-5
b(,)23 b(in)h(lieu)g(of)f(CNRI')-5 b(s)25 b(License)f(Agreement,)e
(Licensee)i(may)f(substitute)h(the)208 1040 y(follo)n(wing)j(te)o(xt)i
(\(omitting)e(the)i(quotes\):)42 b(\223Python)27 b(1.6.1)h(is)h(made)g
(a)n(v)n(ailable)f(subject)h(to)g(the)g(terms)g(and)f(conditions)f(in)
208 1140 y(CNRI')-5 b(s)24 b(License)f(Agreement.)33
b(This)24 b(Agreement)d(together)h(with)i(Python)e(1.6.1)g(may)h(be)g
(located)g(on)g(the)g(Internet)f(using)208 1240 y(the)27
b(follo)n(wing)f(unique,)h(persistent)g(identi\002er)g(\(kno)n(wn)f(as)
i(a)f(handle\):)39 b(1895.22/1013.)j(This)27 b(Agreement)f(may)h(also)h
(be)208 1339 y(obtained)18 b(from)h(a)i(proxy)d(serv)o(er)i(on)g(the)g
(Internet)f(using)g(the)i(follo)n(wing)d(URL:)j Fu(
http://hdl.handle)o
(.)o(ne)o(t/18)o(95)o(.2)o(2/1)o(01)o(3)-6 b Ft(.)g(\224)104
1499 y(3.)41 b(In)16 b(the)h(e)n(v)o(ent)f(Licensee)h(prepares)e(a)j
(deri)n(v)n(ati)n(v)o(e)d(w)o(ork)h(that)h(is)h(based)e(on)h(or)g
(incorporates)d(Python)i(1.6.1)g(or)g(an)o(y)h(part)f(thereof,)208
1599 y(and)25 b(w)o(ants)h(to)f(mak)o(e)g(the)h(deri)n(v)n(ati)n(v)o(e)
d(w)o(ork)i(a)n(v)n(ailable)g(to)h(others)f(as)h(pro)o(vided)d(herein,)
j(then)f(Licensee)g(hereby)f(agrees)h(to)208 1699 y(include)19
b(in)h(an)o(y)f(such)h(w)o(ork)g(a)h(brief)e(summary)g(of)h(the)g
(changes)f(made)h(to)g(Python)f(1.6.1.)104 1859 y(4.)41
b(CNRI)23 b(is)h(making)d(Python)h(1.6.1)f(a)n(v)n(ailable)h(to)h
(Licensee)g(on)f(an)h(\223)-7 b(AS)23 b(IS\224)g(basis.)34
b(CNRI)23 b(MAKES)g(NO)g(REPRESENT)-8 b(A-)208 1959 y(TIONS)25
b(OR)h(W)-10 b(ARRANTIES,)26 b(EXPRESS)g(OR)g(IMPLIED.)f(BY)h(W)-10
b(A)h(Y)26 b(OF)g(EXAMPLE,)f(B)o(UT)h(NO)m(T)f(LIMIT)-8
b(A)f(TION,)208 2058 y(CNRI)20 b(MAKES)f(NO)h(AND)g(DISCLAIMS)f(ANY)h
(REPRESENT)-8 b(A)f(TION)19 b(OR)h(W)-10 b(ARRANTY)21
b(OF)f(MERCHANT)-8 b(ABIL-)208 2158 y(ITY)17 b(OR)h(FITNESS)f(FOR)i
(ANY)e(P)-8 b(AR)j(TICULAR)19 b(PURPOSE)f(OR)g(THA)-9
b(T)17 b(THE)g(USE)h(OF)g(PYTHON)f(1.6.1)f(WILL)i(NO)m(T)208
2257 y(INFRINGE)i(ANY)g(THIRD)h(P)-8 b(AR)j(TY)21 b(RIGHTS.)104
2418 y(5.)41 b(CNRI)25 b(SHALL)g(NO)m(T)g(BE)g(LIABLE)g(T)o(O)f
(LICENSEE)g(OR)i(ANY)f(O)m(THER)g(USERS)h(OF)f(PYTHON)g(1.6.1)e(FOR)j
(ANY)208 2517 y(INCIDENT)-8 b(AL,)18 b(SPECIAL,)h(OR)h(CONSEQ)o
(UENTIAL)f(D)m(AMA)m(GES)f(OR)i(LOSS)g(AS)g(A)g(RESUL)-8
b(T)19 b(OF)h(MODIFYING,)208 2617 y(DISTRIB)o(UTING,)j(OR)h(O)m(THER)-5
b(WISE)24 b(USING)g(PYTHON)g(1.6.1,)f(OR)h(ANY)g(DERIV)-11
b(A)i(TIVE)23 b(THEREOF)-7 b(,)24 b(EVEN)f(IF)208 2717
y(AD)m(VISED)c(OF)i(THE)f(POSSIBILITY)g(THEREOF)-7 b(.)104
2877 y(6.)41 b(This)20 b(License)g(Agreement)e(will)j(automatically)e
(terminate)g(upon)g(a)i(material)f(breach)f(of)h(its)h(terms)f(and)g
(conditions.)104 3037 y(7.)41 b(This)16 b(License)f(Agreement)f(shall)j
(be)e(go)o(v)o(erned)e(by)j(the)f(federal)g(intellectual)h(property)d
(la)o(w)j(of)g(the)g(United)f(States,)i(including)208
3137 y(without)28 b(limitation)g(the)g(federal)g(cop)o(yright)f(la)o(w)
-5 b(,)30 b(and,)g(to)f(the)g(e)o(xtent)e(such)i(U.S.)g(federal)e(la)o
(w)i(does)g(not)f(apply)-5 b(,)29 b(by)g(the)208 3236
y(la)o(w)f(of)h(the)f(Commonwealth)f(of)h(V)-5 b(ir)o(ginia,)30
b(e)o(xcluding)c(V)-5 b(ir)o(ginia')g(s)28 b(con\003ict)g(of)g(la)o(w)h
(pro)o(visions.)49 b(Notwithstanding)27 b(the)208 3336
y(fore)o(going,)c(with)i(re)o(gard)f(to)h(deri)n(v)n(ati)n(v)o(e)e(w)o
(orks)i(based)g(on)g(Python)f(1.6.1)g(that)h(incorporate)e
(non-separable)g(material)h(that)208 3435 y(w)o(as)29
b(pre)n(viously)d(distrib)n(uted)i(under)f(the)h(GNU)h(General)f
(Public)g(License)h(\(GPL\),)f(the)g(la)o(w)h(of)f(the)g(Commonwealth)f
(of)208 3535 y(V)-5 b(ir)o(ginia)19 b(shall)j(go)o(v)o(ern)c(this)k
(License)e(Agreement)g(only)g(as)h(to)g(issues)h(arising)f(under)e(or)i
(with)g(respect)g(to)g(P)o(aragraphs)e(4,)i(5,)208 3635
y(and)d(7)i(of)f(this)h(License)f(Agreement.)k(Nothing)18
b(in)h(this)h(License)f(Agreement)f(shall)i(be)f(deemed)f(to)h(create)g
(an)o(y)g(relationship)208 3734 y(of)24 b(agenc)o(y)-5
b(,)24 b(partnership,)g(or)g(joint)h(v)o(enture)e(between)h(CNRI)h(and)
f(Licensee.)39 b(This)25 b(License)f(Agreement)f(does)i(not)f(grant)208
3834 y(permission)29 b(to)i(use)g(CNRI)g(trademarks)e(or)h(trade)g
(name)g(in)h(a)g(trademark)e(sense)i(to)f(endorse)g(or)g(promote)f
(products)g(or)208 3934 y(services)20 b(of)g(Licensee,)f(or)h(an)o(y)g
(third)f(party)-5 b(.)104 4094 y(8.)41 b(By)17 b(clicking)f(on)g(the)h
(\223)-7 b(A)m(CCEPT\224)18 b(b)n(utton)e(where)g(indicated,)g(or)h(by)
f(cop)o(ying,)g(installing)g(or)h(otherwise)f(using)g(Python)g(1.6.1,)
208 4193 y(Licensee)j(agrees)h(to)h(be)f(bound)e(by)i(the)g(terms)g
(and)g(conditions)e(of)i(this)h(License)f(Agreement.)1793
4362 y(A)m(CCEPT)722 4461 y Fr(CWI)h(LICENSE)h(A)-5 b(GREEMENT)23
b(FOR)d(PYTHON)g(0.9.0)e(THR)n(OUGH)h(1.2)0 4608 y Ft(Cop)o(yright)380
4605 y(c)357 4608 y Fs(\015)h Ft(1991)f(-)i(1995,)d(Stichting)i
(Mathematisch)f(Centrum)g(Amsterdam,)g(The)h(Netherlands.)k(All)d
(rights)e(reserv)o(ed.)0 4755 y(Permission)g(to)h(use,)g(cop)o(y)-5
b(,)19 b(modify)-5 b(,)17 b(and)i(distrib)n(ute)h(this)g(softw)o(are)f
(and)h(its)g(documentation)d(for)i(an)o(y)g(purpose)g(and)g(without)g
(fee)h(is)0 4855 y(hereby)i(granted,)g(pro)o(vided)f(that)i(the)h(abo)o
(v)o(e)d(cop)o(yright)h(notice)g(appear)h(in)g(all)h(copies)f(and)g
(that)g(both)g(that)g(cop)o(yright)e(notice)i(and)0 4954
y(this)f(permission)f(notice)g(appear)f(in)i(supporting)d
(documentation,)g(and)i(that)h(the)f(name)g(of)h(Stichting)f
(Mathematisch)f(Centrum)h(or)0 5054 y(CWI)26 b(not)f(be)h(used)f(in)g
(adv)o(ertising)f(or)h(publicity)f(pertaining)g(to)h(distrib)n(ution)g
(of)g(the)g(softw)o(are)g(without)g(speci\002c,)h(written)g(prior)0
5154 y(permission.)0 5300 y(STICHTING)18 b(MA)-9 b(THEMA)g(TISCH)18
b(CENTR)m(UM)g(DISCLAIMS)h(ALL)f(W)-10 b(ARRANTIES)20
b(WITH)f(REGARD)g(T)o(O)f(THIS)h(SOFT)-8 b(-)0 5400 y(W)e(ARE,)23
b(INCLUDING)e(ALL)h(IMPLIED)f(W)-10 b(ARRANTIES)23 b(OF)g(MERCHANT)-8
b(ABILITY)21 b(AND)i(FITNESS,)e(IN)i(NO)f(EVENT)p 0 5549
3901 4 v 0 5649 a Fp(74)2583 b(Appendix)24 b(A.)47 b(Histor)r(y)22
b(and)i(License)p eop end
%%Page: 75 81
TeXDict begin 75 80 bop 0 83 a Ft(SHALL)30 b(STICHTING)g(MA)-9
b(THEMA)g(TISCH)29 b(CENTR)m(UM)h(BE)g(LIABLE)g(FOR)h(ANY)f(SPECIAL,)g
(INDIRECT)g(OR)h(CON-)0 183 y(SEQ)o(UENTIAL)e(D)m(AMA)m(GES)h(OR)h(ANY)
f(D)m(AMA)m(GES)f(WHA)-9 b(TSOEVER)31 b(RESUL)-8 b(TING)30
b(FR)m(OM)g(LOSS)h(OF)g(USE,)f(D)m(A)-9 b(T)h(A)0 282
y(OR)25 b(PR)m(OFITS,)f(WHETHER)h(IN)f(AN)h(A)m(CTION)f(OF)h(CONTRA)m
(CT)-6 b(,)24 b(NEGLIGENCE)g(OR)h(O)m(THER)f(T)o(OR)-5
b(TIOUS)24 b(A)m(CTION,)0 382 y(ARISING)c(OUT)h(OF)g(OR)g(IN)f
(CONNECTION)g(WITH)h(THE)f(USE)h(OR)g(PERFORMANCE)g(OF)g(THIS)f(SOFTW)
-10 b(ARE.)0 709 y Fm(A.3)120 b(Licenses)34 b(and)h(Ac)n(kno)n
(wledgements)g(f)l(or)f(Incor)t(por)o(ated)i(Softw)n(are)0
942 y Ft(This)18 b(section)f(is)h(an)g(incomplete,)e(b)n(ut)h(gro)n
(wing)f(list)i(of)g(licenses)f(and)g(ackno)n(wledgements)e(for)h
(third-party)f(softw)o(are)i(incorporated)0 1042 y(in)j(the)h(Python)e
(distrib)n(ution.)0 1327 y Fk(A.3.1)100 b(Mersenne)30
b(T)-12 b(wister)0 1530 y Ft(The)15 b Fo(_random)f Ft(module)g
(includes)h(code)f(based)h(on)g(a)g(do)n(wnload)f(from)g
Fu(
http://www)l(.math.k)o(eio)m(.ac.j)o(p/)g(matumoto/MT2002/emt19937)o
(ar)l(.h)o(tml)-6 b Ft(.)0 1629 y(The)20 b(follo)n(wing)e(are)j(the)f
(v)o(erbatim)e(comments)h(from)h(the)g(original)f(code:)p
0 5549 3901 4 v 0 5649 a Fp(A.3.)52 b(Licenses)23 b(and)h(Ac)n(kno)o
(wledgements)g(f)n(or)e(Incor)r(por)o(ated)i(Softw)o(are)1422
b(75)p eop end
%%Page: 76 82
TeXDict begin 76 81 bop 236 174 a Fi(A)45 b(C-program)e(for)i(MT19937,)
e(with)h(initialization)f(improved)g(2002/1/26.)236 266
y(Coded)h(by)h(Takuji)f(Nishimura)f(and)h(Makoto)g(Matsumoto.)236
448 y(Before)g(using,)g(initialize)f(the)h(state)g(by)h(using)f
(init_genrand\(seed\))236 540 y(or)h(init_by_array\(init_key,)c
(key_length\).)236 722 y(Copyright)j(\(C\))g(1997)g(-)h(2002,)f(Makoto)
g(Matsumoto)f(and)h(Takuji)g(Nishimura,)236 814 y(All)h(rights)e
(reserved.)236 996 y(Redistribution)g(and)h(use)g(in)h(source)f(and)g
(binary)g(forms,)g(with)g(or)g(without)236 1088 y(modification,)f(are)h
(permitted)g(provided)f(that)h(the)g(following)g(conditions)236
1179 y(are)h(met:)281 1362 y(1.)g(Redistributions)d(of)i(source)g(code)
g(must)g(retain)g(the)h(above)f(copyright)416 1453 y(notice,)f(this)h
(list)h(of)f(conditions)f(and)h(the)h(following)e(disclaimer.)281
1636 y(2.)i(Redistributions)d(in)i(binary)g(form)g(must)g(reproduce)g
(the)g(above)g(copyright)416 1727 y(notice,)f(this)h(list)h(of)f
(conditions)f(and)h(the)h(following)e(disclaimer)g(in)i(the)416
1818 y(documentation)d(and/or)i(other)g(materials)f(provided)h(with)g
(the)g(distribution.)281 2001 y(3.)h(The)f(names)g(of)g(its)h
(contributors)e(may)h(not)g(be)h(used)f(to)g(endorse)g(or)g(promote)416
2092 y(products)f(derived)h(from)g(this)g(software)f(without)h
(specific)g(prior)g(written)416 2183 y(permission.)236
2366 y(THIS)g(SOFTWARE)g(IS)g(PROVIDED)g(BY)g(THE)h(COPYRIGHT)e
(HOLDERS)h(AND)g(CONTRIBUTORS)236 2457 y("AS)h(IS")f(AND)g(ANY)h
(EXPRESS)e(OR)i(IMPLIED)e(WARRANTIES,)g(INCLUDING,)g(BUT)i(NOT)236
2549 y(LIMITED)f(TO,)g(THE)h(IMPLIED)e(WARRANTIES)g(OF)i
(MERCHANTABILITY)d(AND)i(FITNESS)g(FOR)236 2640 y(A)h(PARTICULAR)e
(PURPOSE)h(ARE)g(DISCLAIMED.)88 b(IN)44 b(NO)h(EVENT)f(SHALL)g(THE)g
(COPYRIGHT)f(OWNER)h(OR)236 2731 y(CONTRIBUTORS)f(BE)i(LIABLE)e(FOR)i
(ANY)f(DIRECT,)g(INDIRECT,)f(INCIDENTAL,)g(SPECIAL,)236
2823 y(EXEMPLARY,)g(OR)i(CONSEQUENTIAL)e(DAMAGES)g(\(INCLUDING,)g(BUT)h
(NOT)h(LIMITED)e(TO,)236 2914 y(PROCUREMENT)g(OF)i(SUBSTITUTE)e(GOODS)h
(OR)g(SERVICES;)g(LOSS)g(OF)g(USE,)g(DATA,)g(OR)236 3005
y(PROFITS;)g(OR)g(BUSINESS)g(INTERRUPTION\))e(HOWEVER)i(CAUSED)g(AND)g
(ON)h(ANY)f(THEORY)g(OF)236 3097 y(LIABILITY,)f(WHETHER)h(IN)h
(CONTRACT,)e(STRICT)h(LIABILITY,)f(OR)h(TORT)g(\(INCLUDING)236
3188 y(NEGLIGENCE)f(OR)i(OTHERWISE\))e(ARISING)h(IN)g(ANY)g(WAY)h(OUT)f
(OF)h(THE)f(USE)g(OF)h(THIS)236 3279 y(SOFTWARE,)f(EVEN)g(IF)g(ADVISED)
g(OF)g(THE)h(POSSIBILITY)e(OF)h(SUCH)g(DAMAGE.)236 3553
y(Any)h(feedback)e(is)i(very)f(welcome.)236 3645 y
(
http://www.math.keio.ac.jp/matumoto/emt.)o(html)236
3736 y(email:)g(
[email protected])0 4161 y Fk(A.3.2)100
b(Soc)n(k)n(ets)0 4364 y Ft(The)23 b Fo(socket)g Ft(module)e(uses)j
(the)g(functions,)e Fo(getaddrinfo)p Ft(,)g(and)h Fo(getnameinfo)p
Ft(,)f(which)h(are)g(coded)f(in)i(separate)e(source)0
4463 y(\002les)f(from)e(the)i(WIDE)f(Project,)g Fu(
http://www)l(.wide)o
(.ad.j)o(p/a)o(bo)o(ut/)o(ind)o(e)m(x.html)-6 b Ft(.)p
0 5549 3901 4 v 0 5649 a Fp(76)2583 b(Appendix)24 b(A.)47
b(Histor)r(y)22 b(and)i(License)p eop end
%%Page: 77 83
TeXDict begin 77 82 bop 236 83 a Fi(Copyright)44 b(\(C\))g(1995,)g
(1996,)g(1997,)g(and)g(1998)g(WIDE)g(Project.)236 174
y(All)h(rights)e(reserved.)236 357 y(Redistribution)g(and)h(use)g(in)h
(source)f(and)g(binary)g(forms,)g(with)g(or)g(without)236
448 y(modification,)f(are)h(permitted)g(provided)f(that)h(the)g
(following)g(conditions)236 540 y(are)h(met:)236 631
y(1.)g(Redistributions)d(of)j(source)e(code)i(must)f(retain)f(the)i
(above)f(copyright)371 722 y(notice,)f(this)i(list)f(of)g(conditions)f
(and)i(the)f(following)f(disclaimer.)236 814 y(2.)i(Redistributions)d
(in)j(binary)e(form)i(must)f(reproduce)f(the)h(above)g(copyright)371
905 y(notice,)f(this)i(list)f(of)g(conditions)f(and)i(the)f(following)f
(disclaimer)g(in)i(the)371 996 y(documentation)d(and/or)i(other)g
(materials)f(provided)h(with)g(the)g(distribution.)236
1088 y(3.)h(Neither)e(the)i(name)f(of)g(the)h(project)e(nor)i(the)f
(names)g(of)g(its)h(contributors)371 1179 y(may)f(be)h(used)f(to)g
(endorse)g(or)g(promote)g(products)f(derived)h(from)g(this)g(software)
371 1270 y(without)f(specific)h(prior)g(written)g(permission.)236
1453 y(THIS)g(SOFTWARE)g(IS)g(PROVIDED)g(BY)g(THE)h(PROJECT)e(AND)i
(CONTRIBUTORS)d(``AS)j(IS'')f(AND)236 1544 y(GAI_ANY)g(EXPRESS)g(OR)g
(IMPLIED)g(WARRANTIES,)f(INCLUDING,)g(BUT)h(NOT)g(LIMITED)g(TO,)g(THE)
236 1636 y(IMPLIED)g(WARRANTIES)f(OF)i(MERCHANTABILITY)d(AND)i(FITNESS)
g(FOR)g(A)h(PARTICULAR)e(PURPOSE)236 1727 y(ARE)i(DISCLAIMED.)87
b(IN)45 b(NO)f(EVENT)g(SHALL)g(THE)h(PROJECT)e(OR)i(CONTRIBUTORS)e(BE)h
(LIABLE)236 1818 y(FOR)h(GAI_ANY)e(DIRECT,)h(INDIRECT,)f(INCIDENTAL,)g
(SPECIAL,)h(EXEMPLARY,)f(OR)h(CONSEQUENTIAL)236 1910
y(DAMAGES)g(\(INCLUDING,)f(BUT)h(NOT)h(LIMITED)e(TO,)h(PROCUREMENT)f
(OF)i(SUBSTITUTE)e(GOODS)236 2001 y(OR)i(SERVICES;)e(LOSS)h(OF)h(USE,)f
(DATA,)g(OR)g(PROFITS;)g(OR)g(BUSINESS)g(INTERRUPTION\))236
2092 y(HOWEVER)g(CAUSED)g(AND)g(ON)h(GAI_ANY)e(THEORY)h(OF)g
(LIABILITY,)g(WHETHER)f(IN)i(CONTRACT,)e(STRICT)236 2183
y(LIABILITY,)g(OR)i(TORT)f(\(INCLUDING)f(NEGLIGENCE)g(OR)i(OTHERWISE\))
e(ARISING)h(IN)g(GAI_ANY)g(WAY)236 2275 y(OUT)h(OF)f(THE)g(USE)h(OF)f
(THIS)g(SOFTWARE,)g(EVEN)g(IF)g(ADVISED)g(OF)g(THE)h(POSSIBILITY)e(OF)
236 2366 y(SUCH)h(DAMAGE.)0 2789 y Fk(A.3.3)100 b(Floating)29
b(point)g(e)m(xception)g(control)0 2992 y Ft(The)20 b(source)f(for)h
(the)g Fo(fpectl)g Ft(module)f(includes)g(the)h(follo)n(wing)f(notice:)
p 0 5549 3901 4 v 0 5649 a Fp(A.3.)52 b(Licenses)23 b(and)h(Ac)n(kno)o
(wledgements)g(f)n(or)e(Incor)r(por)o(ated)i(Softw)o(are)1422
b(77)p eop end
%%Page: 78 84
TeXDict begin 78 83 bop 460 174 a Fi
(-----------------------------------------)o(------)o(------)o(------)o
(------)o(----)416 266 y(/)1031 b(Copyright)43 b(\(c\))h(1996.)1210
b(\\)371 357 y(|)448 b(The)44 b(Regents)g(of)g(the)h(University)e(of)h
(California.)761 b(|)371 448 y(|)1076 b(All)44 b(rights)g(reserved.)
1209 b(|)371 540 y(|)3183 b(|)371 631 y(|)134 b(Permission)43
b(to)i(use,)f(copy,)g(modify,)f(and)i(distribute)e(this)h(software)g
(for)134 b(|)371 722 y(|)g(any)44 b(purpose)g(without)g(fee)g(is)h
(hereby)e(granted,)h(provided)f(that)h(this)h(en-)134
b(|)371 814 y(|)g(tire)44 b(notice)g(is)h(included)e(in)i(all)f(copies)
g(of)g(any)g(software)g(which)g(is)g(or)135 b(|)371 905
y(|)f(includes)88 b(a)i(copy)f(or)g(modification)f(of)h(this)44
b(software)g(and)g(in)h(all)134 b(|)371 996 y(|)g(copies)44
b(of)g(the)h(supporting)e(documentation)f(for)j(such)f(software.)492
b(|)371 1088 y(|)3183 b(|)371 1179 y(|)134 b(This)89
b(work)44 b(was)h(produced)e(at)i(the)f(University)f(of)h(California,)f
(Lawrence)134 b(|)371 1270 y(|)g(Livermore)43 b(National)h(Laboratory)f
(under)89 b(contract)f(no.)h(W-7405-ENG-48)133 b(|)371
1362 y(|)h(between)89 b(the)g(U.S.)g(Department)f(of)h(Energy)44
b(and)g(The)g(Regents)g(of)h(the)134 b(|)371 1453 y(|)g(University)43
b(of)i(California)e(for)h(the)g(operation)g(of)g(UC)h(LLNL.)627
b(|)371 1544 y(|)3183 b(|)371 1636 y(|)1345 b(DISCLAIMER)1388
b(|)371 1727 y(|)3183 b(|)371 1818 y(|)134 b(This)89
b(software)44 b(was)g(prepared)f(as)i(an)f(account)g(of)g(work)h
(sponsored)e(by)h(an)135 b(|)371 1910 y(|)f(agency)44
b(of)g(the)h(United)f(States)f(Government.)g(Neither)h(the)g(United)g
(States)134 b(|)371 2001 y(|)g(Government)88 b(nor)44
b(the)h(University)e(of)h(California)f(nor)i(any)f(of)h(their)f(em-)134
b(|)371 2092 y(|)g(ployees,)44 b(makes)g(any)g(warranty,)f(express)h
(or)g(implied,)g(or)89 b(assumes)g(any)134 b(|)371 2183
y(|)g(liability)88 b(or)i(responsibility)d(for)44 b(the)g(accuracy,)g
(completeness,)e(or)135 b(|)371 2275 y(|)f(usefulness)43
b(of)i(any)f(information,)88 b(apparatus,)g(product,)g(or)h(process)134
b(|)371 2366 y(|)g(disclosed,)f(or)89 b(represents)f(that)h(its)g(use)g
(would)g(not)g(infringe)134 b(|)371 2457 y(|)g(privately-owned)42
b(rights.)i(Reference)f(herein)h(to)h(any)f(specific)88
b(commer-)134 b(|)371 2549 y(|)g(cial)89 b(products,)f(process,)h(or)g
(service)f(by)45 b(trade)f(name,)g(trademark,)133 b(|)371
2640 y(|)h(manufacturer,)43 b(or)h(otherwise,)f(does)h(not)90
b(necessarily)d(constitute)h(or)135 b(|)371 2731 y(|)f(imply)89
b(its)44 b(endorsement,)f(recommendation,)f(or)j(favoring)e(by)i(the)f
(United)134 b(|)371 2823 y(|)g(States)44 b(Government)f(or)i(the)f
(University)f(of)h(California.)f(The)i(views)89 b(and)134
b(|)371 2914 y(|)g(opinions)88 b(of)45 b(authors)f(expressed)f(herein)h
(do)g(not)g(necessarily)f(state)h(or)135 b(|)371 3005
y(|)f(reflect)44 b(those)g(of)g(the)h(United)e(States)h(Government)f
(or)90 b(the)f(University)133 b(|)371 3097 y(|)h(of)89
b(California,)f(and)45 b(shall)f(not)g(be)g(used)g(for)h(advertising)e
(or)h(product)134 b(|)416 3188 y(\\)89 b(endorsement)43
b(purposes.)2061 b(/)460 3279 y
(-----------------------------------------)o(------)o(------)o(------)o
(------)o(----)0 3703 y Fk(A.3.4)100 b(MD5)28 b(message)h(digest)g
(algor)q(ithm)0 3906 y Ft(The)20 b(source)f(code)h(for)f(the)i
Fo(md5)f Ft(module)f(contains)g(the)h(follo)n(wing)f(notice:)p
0 5549 3901 4 v 0 5649 a Fp(78)2583 b(Appendix)24 b(A.)47
b(Histor)r(y)22 b(and)i(License)p eop end
%%Page: 79 85
TeXDict begin 79 84 bop 326 174 a Fi(Copyright)43 b(\(C\))i(1999,)f
(2002)g(Aladdin)f(Enterprises.)88 b(All)44 b(rights)g(reserved.)326
357 y(This)g(software)g(is)g(provided)g('as-is',)f(without)h(any)g
(express)g(or)g(implied)326 448 y(warranty.)88 b(In)45
b(no)f(event)g(will)g(the)h(authors)e(be)i(held)f(liable)g(for)g(any)g
(damages)326 540 y(arising)g(from)g(the)g(use)g(of)h(this)f(software.)
326 722 y(Permission)f(is)i(granted)e(to)i(anyone)f(to)g(use)g(this)g
(software)g(for)g(any)h(purpose,)326 814 y(including)e(commercial)g
(applications,)g(and)h(to)h(alter)f(it)g(and)h(redistribute)d(it)326
905 y(freely,)i(subject)f(to)i(the)f(following)f(restrictions:)326
1088 y(1.)h(The)h(origin)f(of)g(this)g(software)g(must)g(not)g(be)h
(misrepresented;)d(you)i(must)g(not)460 1179 y(claim)g(that)h(you)f
(wrote)g(the)g(original)g(software.)f(If)h(you)h(use)f(this)g(software)
460 1270 y(in)h(a)g(product,)e(an)i(acknowledgment)d(in)i(the)h
(product)e(documentation)g(would)h(be)460 1362 y(appreciated)f(but)i
(is)f(not)h(required.)326 1453 y(2.)f(Altered)g(source)g(versions)f
(must)i(be)f(plainly)g(marked)f(as)i(such,)f(and)g(must)g(not)h(be)460
1544 y(misrepresented)e(as)h(being)g(the)h(original)e(software.)326
1636 y(3.)h(This)h(notice)e(may)i(not)f(be)h(removed)e(or)i(altered)e
(from)h(any)h(source)f(distribution.)326 1818 y(L.)g(Peter)g(Deutsch)
326 1910 y(
[email protected])326 2092 y(Independent)f(implementation)f
(of)j(MD5)f(\(RFC)g(1321\).)326 2275 y(This)g(code)g(implements)f(the)i
(MD5)f(Algorithm)f(defined)h(in)g(RFC)h(1321,)f(whose)326
2366 y(text)g(is)h(available)e(at)236 2457 y
(
http://www.ietf.org/rfc/rfc1321.txt)326 2549 y(The)h(code)g(is)h
(derived)f(from)g(the)g(text)g(of)h(the)f(RFC,)g(including)f(the)i
(test)f(suite)326 2640 y(\(section)f(A.5\))i(but)f(excluding)f(the)i
(rest)f(of)g(Appendix)g(A.)89 b(It)44 b(does)h(not)f(include)326
2731 y(any)g(code)g(or)h(documentation)e(that)h(is)g(identified)f(in)i
(the)f(RFC)g(as)h(being)326 2823 y(copyrighted.)326 3005
y(The)f(original)g(and)g(principal)f(author)h(of)h(md5.h)f(is)g(L.)h
(Peter)f(Deutsch)326 3097 y(<
[email protected]>.)86 b(Other)44
b(authors)g(are)g(noted)g(in)h(the)f(change)g(history)326
3188 y(that)g(follows)g(\(in)g(reverse)g(chronological)e(order\):)326
3371 y(2002-04-13)h(lpd)h(Removed)g(support)g(for)g(non-ANSI)f
(compilers;)h(removed)236 3462 y(references)f(to)i(Ghostscript;)e
(clarified)g(derivation)g(from)h(RFC)h(1321;)236 3553
y(now)g(handles)e(byte)h(order)g(either)g(statically)f(or)i
(dynamically.)326 3645 y(1999-11-04)e(lpd)h(Edited)g(comments)g
(slightly)f(for)h(automatic)g(TOC)g(extraction.)326 3736
y(1999-10-18)f(lpd)h(Fixed)g(typo)h(in)f(header)g(comment)f(\(ansi2knr)
h(rather)g(than)g(md5\);)236 3827 y(added)g(conditionalization)e(for)i
(C++)h(compilation)e(from)h(Martin)236 3919 y(Purschke)g
(<
[email protected]>.)326 4010 y(1999-05-03)f(lpd)h(Original)g(version.)
0 4433 y Fk(A.3.5)100 b(Asynchronous)30 b(soc)n(k)n(et)e(ser)s(vices)0
4636 y Ft(The)20 b Fo(asynchat)f Ft(and)h Fo(asyncore)f
Ft(modules)g(contain)g(the)i(follo)n(wing)d(notice:)p
0 5549 3901 4 v 0 5649 a Fp(A.3.)52 b(Licenses)23 b(and)h(Ac)n(kno)o
(wledgements)g(f)n(or)e(Incor)r(por)o(ated)i(Softw)o(are)1422
b(79)p eop end
%%Page: 80 86
TeXDict begin 80 85 bop 281 174 a Fi(Copyright)43 b(1996)i(by)f(Sam)g
(Rushing)1357 357 y(All)g(Rights)g(Reserved)281 540 y(Permission)f(to)i
(use,)f(copy,)g(modify,)g(and)g(distribute)f(this)h(software)g(and)281
631 y(its)g(documentation)f(for)h(any)h(purpose)e(and)i(without)e(fee)i
(is)f(hereby)281 722 y(granted,)g(provided)f(that)h(the)h(above)f
(copyright)f(notice)h(appear)f(in)i(all)281 814 y(copies)f(and)g(that)g
(both)h(that)f(copyright)f(notice)h(and)g(this)g(permission)281
905 y(notice)g(appear)g(in)g(supporting)f(documentation,)g(and)h(that)g
(the)h(name)f(of)g(Sam)281 996 y(Rushing)g(not)g(be)h(used)f(in)g
(advertising)f(or)i(publicity)e(pertaining)g(to)281 1088
y(distribution)g(of)h(the)h(software)e(without)h(specific,)f(written)h
(prior)281 1179 y(permission.)281 1362 y(SAM)g(RUSHING)g(DISCLAIMS)f
(ALL)i(WARRANTIES)e(WITH)h(REGARD)g(TO)g(THIS)g(SOFTWARE,)281
1453 y(INCLUDING)f(ALL)i(IMPLIED)e(WARRANTIES)h(OF)g(MERCHANTABILITY)e
(AND)j(FITNESS,)e(IN)281 1544 y(NO)i(EVENT)f(SHALL)g(SAM)g(RUSHING)g
(BE)g(LIABLE)g(FOR)g(ANY)g(SPECIAL,)g(INDIRECT)f(OR)281
1636 y(CONSEQUENTIAL)g(DAMAGES)g(OR)i(ANY)f(DAMAGES)g(WHATSOEVER)f
(RESULTING)g(FROM)h(LOSS)281 1727 y(OF)h(USE,)f(DATA)g(OR)g(PROFITS,)g
(WHETHER)g(IN)g(AN)g(ACTION)g(OF)h(CONTRACT,)281 1818
y(NEGLIGENCE)e(OR)i(OTHER)f(TORTIOUS)f(ACTION,)h(ARISING)f(OUT)i(OF)f
(OR)h(IN)281 1910 y(CONNECTION)e(WITH)h(THE)h(USE)f(OR)h(PERFORMANCE)d
(OF)j(THIS)f(SOFTWARE.)0 2334 y Fk(A.3.6)100 b(Cookie)29
b(management)0 2537 y Ft(The)20 b Fo(Cookie)f Ft(module)g(contains)h
(the)g(follo)n(wing)f(notice:)281 2775 y Fi(Copyright)43
b(2000)i(by)f(Timothy)g(O'Malley)f(<
[email protected]>)954
2958 y(All)h(Rights)g(Reserved)281 3141 y(Permission)f(to)i(use,)f
(copy,)g(modify,)g(and)g(distribute)f(this)h(software)281
3232 y(and)g(its)h(documentation)d(for)j(any)f(purpose)g(and)g(without)
g(fee)g(is)g(hereby)281 3323 y(granted,)g(provided)f(that)h(the)h
(above)f(copyright)f(notice)h(appear)f(in)i(all)281 3415
y(copies)f(and)g(that)g(both)h(that)f(copyright)f(notice)h(and)g(this)g
(permission)281 3506 y(notice)g(appear)g(in)g(supporting)f
(documentation,)g(and)h(that)g(the)h(name)f(of)281 3597
y(Timothy)g(O'Malley)88 b(not)44 b(be)h(used)f(in)h(advertising)d(or)j
(publicity)281 3689 y(pertaining)e(to)i(distribution)e(of)h(the)g
(software)g(without)f(specific,)h(written)281 3780 y(prior)g
(permission.)281 3963 y(Timothy)g(O'Malley)f(DISCLAIMS)h(ALL)g
(WARRANTIES)f(WITH)h(REGARD)g(TO)g(THIS)281 4054 y(SOFTWARE,)f
(INCLUDING)h(ALL)g(IMPLIED)g(WARRANTIES)f(OF)h(MERCHANTABILITY)281
4145 y(AND)g(FITNESS,)g(IN)g(NO)h(EVENT)f(SHALL)g(Timothy)f(O'Malley)h
(BE)g(LIABLE)g(FOR)281 4237 y(ANY)g(SPECIAL,)g(INDIRECT)f(OR)i
(CONSEQUENTIAL)d(DAMAGES)i(OR)h(ANY)f(DAMAGES)281 4328
y(WHATSOEVER)f(RESULTING)h(FROM)g(LOSS)g(OF)g(USE,)g(DATA)h(OR)f
(PROFITS,)281 4419 y(WHETHER)g(IN)g(AN)h(ACTION)f(OF)g(CONTRACT,)f
(NEGLIGENCE)g(OR)i(OTHER)f(TORTIOUS)281 4511 y(ACTION,)g(ARISING)f(OUT)
i(OF)f(OR)h(IN)f(CONNECTION)f(WITH)h(THE)h(USE)f(OR)281
4602 y(PERFORMANCE)f(OF)i(THIS)f(SOFTWARE.)0 5026 y Fk(A.3.7)100
b(Pro\002ling)0 5229 y Ft(The)20 b Fo(profile)f Ft(and)h
Fo(pstats)g Ft(modules)f(contain)g(the)h(follo)n(wing)f(notice:)p
0 5549 3901 4 v 0 5649 a Fp(80)2583 b(Appendix)24 b(A.)47
b(Histor)r(y)22 b(and)i(License)p eop end
%%Page: 81 87
TeXDict begin 81 86 bop 281 174 a Fi(Copyright)43 b(1994,)h(by)h
(InfoSeek)e(Corporation,)g(all)h(rights)g(reserved.)281
266 y(Written)g(by)g(James)g(Roskind)281 448 y(Permission)f(to)i(use,)f
(copy,)g(modify,)g(and)g(distribute)f(this)h(Python)g(software)281
540 y(and)g(its)h(associated)e(documentation)g(for)h(any)g(purpose)g
(\(subject)f(to)i(the)281 631 y(restriction)e(in)i(the)f(following)f
(sentence\))g(without)h(fee)g(is)h(hereby)f(granted,)281
722 y(provided)g(that)g(the)g(above)g(copyright)f(notice)h(appears)g
(in)g(all)h(copies,)e(and)281 814 y(that)h(both)g(that)h(copyright)e
(notice)h(and)g(this)g(permission)f(notice)h(appear)g(in)281
905 y(supporting)f(documentation,)g(and)h(that)g(the)g(name)h(of)f
(InfoSeek)g(not)g(be)g(used)h(in)281 996 y(advertising)e(or)i
(publicity)e(pertaining)g(to)h(distribution)f(of)i(the)f(software)281
1088 y(without)g(specific,)f(written)h(prior)g(permission.)87
b(This)45 b(permission)e(is)281 1179 y(explicitly)g(restricted)g(to)i
(the)f(copying)g(and)g(modification)f(of)h(the)h(software)281
1270 y(to)g(remain)e(in)i(Python,)f(compiled)f(Python,)h(or)g(other)g
(languages)f(\(such)h(as)h(C\))281 1362 y(wherein)f(the)g(modified)g
(or)g(derived)g(code)g(is)g(exclusively)f(imported)h(into)g(a)281
1453 y(Python)g(module.)281 1636 y(INFOSEEK)g(CORPORATION)f(DISCLAIMS)g
(ALL)h(WARRANTIES)f(WITH)h(REGARD)g(TO)h(THIS)281 1727
y(SOFTWARE,)e(INCLUDING)h(ALL)g(IMPLIED)g(WARRANTIES)f(OF)h
(MERCHANTABILITY)f(AND)281 1818 y(FITNESS.)h(IN)g(NO)h(EVENT)f(SHALL)g
(INFOSEEK)f(CORPORATION)g(BE)h(LIABLE)g(FOR)h(ANY)281
1910 y(SPECIAL,)f(INDIRECT)f(OR)i(CONSEQUENTIAL)d(DAMAGES)i(OR)g(ANY)h
(DAMAGES)e(WHATSOEVER)281 2001 y(RESULTING)g(FROM)i(LOSS)f(OF)g(USE,)g
(DATA)h(OR)f(PROFITS,)f(WHETHER)h(IN)h(AN)f(ACTION)g(OF)281
2092 y(CONTRACT,)f(NEGLIGENCE)h(OR)g(OTHER)g(TORTIOUS)f(ACTION,)h
(ARISING)g(OUT)g(OF)h(OR)f(IN)281 2183 y(CONNECTION)f(WITH)h(THE)h(USE)
f(OR)h(PERFORMANCE)d(OF)j(THIS)f(SOFTWARE.)0 2607 y Fk(A.3.8)100
b(Ex)m(ecution)29 b(tr)o(acing)0 2810 y Ft(The)20 b Fo(trace)g
Ft(module)e(contains)i(the)g(follo)n(wing)f(notice:)p
0 5549 3901 4 v 0 5649 a Fp(A.3.)52 b(Licenses)23 b(and)h(Ac)n(kno)o
(wledgements)g(f)n(or)e(Incor)r(por)o(ated)i(Softw)o(are)1422
b(81)p eop end
%%Page: 82 88
TeXDict begin 82 87 bop 281 174 a Fi(portions)44 b(copyright)f(2001,)h
(Autonomous)f(Zones)h(Industries,)f(Inc.,)h(all)g(rights...)281
266 y(err...)89 b(reserved)43 b(and)i(offered)e(to)i(the)f(public)g
(under)g(the)g(terms)g(of)h(the)281 357 y(Python)f(2.2)g(license.)281
448 y(Author:)g(Zooko)g(O'Whielacronx)281 540 y(
http://zooko.com/)281
631 y(mailto:
[email protected])281 814 y(Copyright)f(2000,)h(Mojam)g
(Media,)g(Inc.,)g(all)g(rights)g(reserved.)281 905 y(Author:)g(Skip)g
(Montanaro)281 1088 y(Copyright)f(1999,)h(Bioreason,)g(Inc.,)g(all)g
(rights)g(reserved.)281 1179 y(Author:)g(Andrew)g(Dalke)281
1362 y(Copyright)f(1995-1997,)h(Automatrix,)f(Inc.,)g(all)i(rights)f
(reserved.)281 1453 y(Author:)g(Skip)g(Montanaro)281
1636 y(Copyright)f(1991-1995,)h(Stichting)f(Mathematisch)g(Centrum,)g
(all)h(rights)g(reserved.)281 1910 y(Permission)f(to)i(use,)f(copy,)g
(modify,)g(and)g(distribute)f(this)h(Python)g(software)f(and)281
2001 y(its)h(associated)g(documentation)e(for)j(any)f(purpose)f
(without)h(fee)g(is)h(hereby)281 2092 y(granted,)f(provided)f(that)h
(the)h(above)f(copyright)f(notice)h(appears)f(in)i(all)f(copies,)281
2183 y(and)g(that)h(both)f(that)g(copyright)f(notice)h(and)g(this)g
(permission)g(notice)f(appear)h(in)281 2275 y(supporting)f
(documentation,)g(and)h(that)g(the)g(name)h(of)f(neither)g(Automatrix,)
281 2366 y(Bioreason)f(or)i(Mojam)f(Media)g(be)g(used)h(in)f
(advertising)f(or)h(publicity)g(pertaining)f(to)281 2457
y(distribution)g(of)h(the)h(software)e(without)h(specific,)f(written)h
(prior)g(permission.)0 2882 y Fk(A.3.9)100 b(UUencode)30
b(and)e(UUdecode)i(functions)0 3084 y Ft(The)20 b Fo(uu)g
Ft(module)f(contains)h(the)g(follo)n(wing)e(notice:)p
0 5549 3901 4 v 0 5649 a Fp(82)2583 b(Appendix)24 b(A.)47
b(Histor)r(y)22 b(and)i(License)p eop end
%%Page: 83 89
TeXDict begin 83 88 bop 281 174 a Fi(Copyright)43 b(1994)i(by)f(Lance)g
(Ellinghouse)281 266 y(Cathedral)f(City,)h(California)g(Republic,)f
(United)h(States)f(of)i(America.)1312 357 y(All)g(Rights)e(Reserved)281
448 y(Permission)g(to)i(use,)f(copy,)g(modify,)g(and)g(distribute)f
(this)h(software)g(and)g(its)281 540 y(documentation)f(for)h(any)g
(purpose)g(and)g(without)g(fee)g(is)h(hereby)f(granted,)281
631 y(provided)g(that)g(the)g(above)g(copyright)f(notice)h(appear)g(in)
g(all)h(copies)f(and)g(that)281 722 y(both)g(that)g(copyright)g(notice)
g(and)g(this)g(permission)f(notice)h(appear)g(in)281
814 y(supporting)f(documentation,)g(and)h(that)g(the)g(name)h(of)f
(Lance)g(Ellinghouse)281 905 y(not)g(be)h(used)f(in)h(advertising)e(or)
h(publicity)f(pertaining)g(to)i(distribution)281 996
y(of)g(the)f(software)f(without)h(specific,)f(written)h(prior)g
(permission.)281 1088 y(LANCE)g(ELLINGHOUSE)f(DISCLAIMS)g(ALL)i
(WARRANTIES)e(WITH)h(REGARD)g(TO)281 1179 y(THIS)g(SOFTWARE,)g
(INCLUDING)f(ALL)h(IMPLIED)g(WARRANTIES)f(OF)h(MERCHANTABILITY)f(AND)
281 1270 y(FITNESS,)h(IN)g(NO)h(EVENT)f(SHALL)g(LANCE)g(ELLINGHOUSE)e
(CENTRUM)i(BE)h(LIABLE)281 1362 y(FOR)f(ANY)h(SPECIAL,)e(INDIRECT)h(OR)
g(CONSEQUENTIAL)f(DAMAGES)g(OR)i(ANY)f(DAMAGES)281 1453
y(WHATSOEVER)f(RESULTING)h(FROM)g(LOSS)g(OF)g(USE,)g(DATA)h(OR)f
(PROFITS,)g(WHETHER)f(IN)i(AN)281 1544 y(ACTION)f(OF)g(CONTRACT,)g
(NEGLIGENCE)f(OR)h(OTHER)g(TORTIOUS)g(ACTION,)f(ARISING)h(OUT)281
1636 y(OF)h(OR)f(IN)h(CONNECTION)e(WITH)h(THE)g(USE)h(OR)f(PERFORMANCE)
f(OF)h(THIS)h(SOFTWARE.)281 1818 y(Modified)f(by)g(Jack)g(Jansen,)g
(CWI,)g(July)g(1995:)281 1910 y(-)h(Use)f(binascii)g(module)f(to)i(do)f
(the)h(actual)e(line-by-line)g(conversion)371 2001 y(between)g(ascii)h
(and)h(binary.)e(This)i(results)e(in)i(a)f(1000-fold)g(speedup.)f(The)h
(C)371 2092 y(version)f(is)i(still)f(5)h(times)f(faster,)f(though.)281
2183 y(-)i(Arguments)e(more)h(compliant)g(with)g(python)f(standard)0
2608 y Fk(A.3.10)101 b(XML)28 b(Remote)h(Procedure)h(Calls)0
2811 y Ft(The)20 b Fo(xmlrpclib)f Ft(module)g(contains)g(the)h(follo)n
(wing)f(notice:)p 0 5549 3901 4 v 0 5649 a Fp(A.3.)52
b(Licenses)23 b(and)h(Ac)n(kno)o(wledgements)g(f)n(or)e(Incor)r(por)o
(ated)i(Softw)o(are)1422 b(83)p eop end
%%Page: 84 90
TeXDict begin 84 89 bop 460 174 a Fi(The)45 b(XML-RPC)e(client)h
(interface)g(is)281 357 y(Copyright)f(\(c\))i(1999-2002)e(by)i(Secret)e
(Labs)h(AB)281 448 y(Copyright)f(\(c\))i(1999-2002)e(by)i(Fredrik)e
(Lundh)281 631 y(By)i(obtaining,)e(using,)h(and/or)f(copying)h(this)g
(software)g(and/or)f(its)281 722 y(associated)g(documentation,)g(you)h
(agree)g(that)g(you)g(have)h(read,)f(understood,)281
814 y(and)g(will)h(comply)e(with)i(the)f(following)f(terms)h(and)g
(conditions:)281 996 y(Permission)f(to)i(use,)f(copy,)g(modify,)g(and)g
(distribute)f(this)h(software)g(and)281 1088 y(its)g(associated)g
(documentation)e(for)j(any)f(purpose)f(and)i(without)e(fee)i(is)281
1179 y(hereby)f(granted,)f(provided)h(that)g(the)g(above)g(copyright)g
(notice)f(appears)h(in)281 1270 y(all)g(copies,)g(and)g(that)h(both)f
(that)g(copyright)f(notice)h(and)g(this)g(permission)281
1362 y(notice)g(appear)g(in)g(supporting)f(documentation,)g(and)h(that)
g(the)h(name)f(of)281 1453 y(Secret)g(Labs)g(AB)h(or)f(the)g(author)g
(not)h(be)f(used)g(in)h(advertising)e(or)h(publicity)281
1544 y(pertaining)f(to)i(distribution)e(of)h(the)g(software)g(without)f
(specific,)h(written)281 1636 y(prior)g(permission.)281
1818 y(SECRET)g(LABS)g(AB)h(AND)f(THE)g(AUTHOR)g(DISCLAIMS)f(ALL)i
(WARRANTIES)e(WITH)h(REGARD)281 1910 y(TO)h(THIS)f(SOFTWARE,)f
(INCLUDING)g(ALL)i(IMPLIED)e(WARRANTIES)g(OF)i(MERCHANT-)281
2001 y(ABILITY)f(AND)g(FITNESS.)88 b(IN)45 b(NO)f(EVENT)g(SHALL)g
(SECRET)g(LABS)g(AB)h(OR)f(THE)h(AUTHOR)281 2092 y(BE)g(LIABLE)e(FOR)i
(ANY)f(SPECIAL,)g(INDIRECT)f(OR)h(CONSEQUENTIAL)f(DAMAGES)h(OR)g(ANY)
281 2183 y(DAMAGES)g(WHATSOEVER)f(RESULTING)g(FROM)h(LOSS)g(OF)h(USE,)f
(DATA)g(OR)h(PROFITS,)281 2275 y(WHETHER)f(IN)g(AN)h(ACTION)f(OF)g
(CONTRACT,)f(NEGLIGENCE)g(OR)i(OTHER)f(TORTIOUS)281 2366
y(ACTION,)g(ARISING)f(OUT)i(OF)f(OR)h(IN)f(CONNECTION)f(WITH)h(THE)h
(USE)f(OR)h(PERFORMANCE)281 2457 y(OF)g(THIS)f(SOFTWARE.)p
0 5549 3901 4 v 0 5649 a Fp(84)2583 b(Appendix)24 b(A.)47
b(Histor)r(y)22 b(and)i(License)p eop end
%%Page: 85 91
TeXDict begin 85 90 bop 3269 564 a Fz(INDEX)0 1317 y
Fm(Symbols)0 1440 y Fo(__abs__\(\))19 b Ft(\(numeric)g(object)g
(method\),)f(31)0 1540 y Fo(__add__\(\))166 1639 y Ft(numeric)h(object)
h(method,)e(30)166 1739 y(sequence)h(object)h(method,)e(28)0
1838 y Fo(__all__)h Ft(\(optional)g(module)g(attrib)n(ute\),)g(60)0
1938 y Fo(__and__\(\))g Ft(\(numeric)g(object)g(method\),)f(30)0
2038 y Fo(__bases__)h Ft(\(class)i(attrib)n(ute\),)e(19)0
2137 y Fo(__builtin__)g Ft(\(b)n(uilt-in)g(module\),)f(62,)i(69)0
2237 y Fo(__builtins__)p Ft(,)e(62)0 2337 y Fo(__call__\(\))166
2436 y Ft(object)i(method,)e(46)166 2536 y(object)i(method,)e(27)0
2635 y Fo(__class__)h Ft(\(instance)h(attrib)n(ute\),)f(19)0
2735 y Fo(__cmp__\(\))166 2835 y Ft(object)h(method,)e(24)166
2934 y(object)i(method,)e(23)0 3034 y Fo(__coerce__\(\))166
3134 y Ft(numeric)h(object)h(method,)e(28)166 3233 y(numeric)h(object)h
(method,)e(31)0 3333 y Fo(__complex__\(\))g Ft(\(numeric)h(object)g
(method\),)g(31)0 3432 y Fo(__contains__\(\))166 3532
y Ft(container)g(object)g(method,)g(28)166 3632 y(mapping)f(object)i
(method,)f(28)166 3731 y(sequence)g(object)h(method,)e(28)0
3831 y Fo(__debug__)p Ft(,)h(54)0 3931 y Fo(__del__\(\))g
Ft(\(object)g(method\),)g(22)0 4030 y Fo(__delattr__\(\))f
Ft(\(object)i(method\),)e(25)0 4130 y Fo(__delete__\(\))h
Ft(\(object)g(method\),)f(25)0 4229 y Fo(__delitem__\(\))g
Ft(\(container)h(object)g(method\),)g(28)0 4329 y Fo(__delslice__\(\))f
Ft(\(sequence)h(object)g(method\),)g(29)0 4429 y Fo(__dict__)166
4528 y Ft(class)i(attrib)n(ute,)f(19)166 4628 y(function)f(attrib)n
(ute,)g(17)166 4728 y(instance)h(attrib)n(ute,)f(19,)h(25)166
4827 y(module)f(attrib)n(ute,)g(18)0 4927 y Fo(__div__\(\))g
Ft(\(numeric)g(object)g(method\),)f(30)0 5026 y Fo(__divmod__\(\))h
Ft(\(numeric)f(object)i(method\),)e(30)0 5126 y Fo(__doc__)166
5226 y Ft(class)j(attrib)n(ute,)f(19)166 5325 y(function)f(attrib)n
(ute,)g(17)2158 1312 y(method)f(attrib)n(ute,)i(17)2158
1411 y(module)e(attrib)n(ute,)i(18)1992 1511 y Fo(__enter__\(\))e
Ft(\(conte)o(xt)h(manager)f(method\),)h(33)1992 1610
y Fo(__eq__\(\))g Ft(\(object)g(method\),)f(23)1992 1710
y Fo(__exit__\(\))g Ft(\(conte)o(xt)h(manager)g(method\),)f(33)1992
1810 y Fo(__file__)h Ft(\(module)f(attrib)n(ute\),)h(18)1992
1909 y Fo(__float__\(\))f Ft(\(numeric)h(object)g(method\),)g(31)1992
2009 y Fo(__floordiv__\(\))f Ft(\(numeric)g(object)i(method\),)e(30)
1992 2109 y Fo(__ge__\(\))h Ft(\(object)g(method\),)f(23)1992
2208 y Fo(__get__\(\))h Ft(\(object)g(method\),)f(25)1992
2308 y Fo(__getattr__\(\))g Ft(\(object)h(method\),)f(24)1992
2407 y Fo(__getattribute__\(\))f Ft(\(object)i(method\),)f(25)1992
2507 y Fo(__getitem__\(\))2158 2607 y Ft(container)g(object)i(method,)e
(28)2158 2706 y(mapping)g(object)i(method,)e(22)1992
2806 y Fo(__getslice__\(\))g Ft(\(sequence)g(object)i(method\),)e(29)
1992 2906 y Fo(__gt__\(\))h Ft(\(object)g(method\),)f(23)1992
3005 y Fo(__hash__\(\))g Ft(\(object)i(method\),)e(24)1992
3105 y Fo(__hex__\(\))h Ft(\(numeric)f(object)i(method\),)e(31)1992
3204 y Fo(__iadd__\(\))2158 3304 y Ft(numeric)g(object)i(method,)f(31)
2158 3404 y(sequence)g(object)g(method,)g(28)1992 3503
y Fo(__iand__\(\))f Ft(\(numeric)h(object)h(method\),)e(31)1992
3603 y Fo(__idiv__\(\))g Ft(\(numeric)h(object)h(method\),)e(31)1992
3703 y Fo(__ifloordiv__\(\))f Ft(\(numeric)i(object)h(method\),)e(31)
1992 3802 y Fo(__ilshift__\(\))g Ft(\(numeric)g(object)i(method\),)e
(31)1992 3902 y Fo(__imod__\(\))g Ft(\(numeric)h(object)h(method\),)e
(31)1992 4001 y Fo(__import__\(\))g Ft(\(b)n(uilt-in)h(function\),)f
(60)1992 4101 y Fo(__imul__\(\))2158 4201 y Ft(numeric)g(object)i
(method,)f(31)2158 4300 y(sequence)g(object)g(method,)g(28)1992
4400 y Fo(__index__\(\))f Ft(\(numeric)h(object)g(method\),)g(31)1992
4500 y Fo(__init__\(\))2158 4599 y Ft(object)g(method,)g(18)2158
4699 y(object)g(method,)g(22)1992 4798 y Fo(__init__.py)p
Ft(,)f(60)1992 4898 y Fo(__int__\(\))h Ft(\(numeric)f(object)i
(method\),)e(31)1992 4998 y Fo(__invert__\(\))g Ft(\(numeric)g(object)i
(method\),)e(31)1992 5097 y Fo(__ior__\(\))h Ft(\(numeric)f(object)i
(method\),)e(31)1992 5197 y Fo(__ipow__\(\))g Ft(\(numeric)h(object)h
(method\),)e(31)1992 5297 y Fo(__irshift__\(\))g Ft(\(numeric)g(object)
i(method\),)e(31)1992 5396 y Fo(__isub__\(\))g Ft(\(numeric)h(object)h
(method\),)e(31)p 0 5549 3901 4 v 3808 5649 a Fp(85)p
eop end
%%Page: 86 92
TeXDict begin 86 91 bop 0 83 a Fo(__iter__\(\))166 183
y Ft(container)19 b(object)g(method,)g(28)166 282 y(sequence)g(object)h
(method,)e(28)0 382 y Fo(__itruediv__\(\))g Ft(\(numeric)h(object)g
(method\),)f(31)0 482 y Fo(__ixor__\(\))h Ft(\(numeric)f(object)i
(method\),)e(31)0 581 y Fo(__le__\(\))h Ft(\(object)h(method\),)e(23)0
681 y Fo(__len__\(\))166 780 y Ft(container)h(object)g(method,)g(28)166
880 y(mapping)f(object)i(method,)f(24)0 980 y Fo(__long__\(\))g
Ft(\(numeric)f(object)i(method\),)e(31)0 1079 y Fo(__lshift__\(\))h
Ft(\(numeric)f(object)i(method\),)e(30)0 1179 y Fo(__lt__\(\))h
Ft(\(object)h(method\),)e(23)0 1279 y Fo(__main__)h Ft(\(b)n(uilt-in)g
(module\),)g(36,)g(69)0 1378 y Fo(__metaclass__)f Ft(\(data)i(in)g(\),)
h(27)0 1478 y Fo(__mod__\(\))e Ft(\(numeric)g(object)g(method\),)f(30)0
1577 y Fo(__module__)166 1677 y Ft(class)j(attrib)n(ute,)f(19)166
1777 y(function)f(attrib)n(ute,)g(17)166 1876 y(method)g(attrib)n(ute,)
g(17)0 1976 y Fo(__mul__\(\))166 2076 y Ft(numeric)g(object)h(method,)e
(30)166 2175 y(sequence)h(object)h(method,)e(28)0 2275
y Fo(__name__)166 2374 y Ft(class)j(attrib)n(ute,)f(19)166
2474 y(function)f(attrib)n(ute,)g(17)166 2574 y(method)g(attrib)n(ute,)
g(17)166 2673 y(module)g(attrib)n(ute,)g(18)0 2773 y
Fo(__ne__\(\))g Ft(\(object)h(method\),)e(23)0 2873 y
Fo(__neg__\(\))h Ft(\(numeric)g(object)g(method\),)f(31)0
2972 y Fo(__new__\(\))h Ft(\(object)g(method\),)g(22)0
3072 y Fo(__nonzero__\(\))166 3171 y Ft(object)h(method,)e(28)166
3271 y(object)i(method,)e(24)0 3371 y Fo(__oct__\(\))h
Ft(\(numeric)g(object)g(method\),)f(31)0 3470 y Fo(__or__\(\))h
Ft(\(numeric)g(object)g(method\),)g(30)0 3570 y Fo(__pos__\(\))g
Ft(\(numeric)g(object)g(method\),)f(31)0 3670 y Fo(__pow__\(\))h
Ft(\(numeric)g(object)g(method\),)f(30)0 3769 y Fo(__radd__\(\))166
3869 y Ft(numeric)h(object)h(method,)e(30)166 3968 y(sequence)h(object)
h(method,)e(28)0 4068 y Fo(__rand__\(\))h Ft(\(numeric)f(object)i
(method\),)e(30)0 4168 y Fo(__rcmp__\(\))h Ft(\(object)g(method\),)f
(24)0 4267 y Fo(__rdiv__\(\))h Ft(\(numeric)f(object)i(method\),)e(30)0
4367 y Fo(__rdivmod__\(\))g Ft(\(numeric)h(object)g(method\),)g(30)0
4467 y Fo(__repr__\(\))g Ft(\(object)g(method\),)f(23)0
4566 y Fo(__rfloordiv__\(\))g Ft(\(numeric)g(object)i(method\),)e(30)0
4666 y Fo(__rlshift__\(\))g Ft(\(numeric)h(object)g(method\),)g(30)0
4765 y Fo(__rmod__\(\))g Ft(\(numeric)f(object)i(method\),)e(30)0
4865 y Fo(__rmul__\(\))166 4965 y Ft(numeric)h(object)h(method,)e(30)
166 5064 y(sequence)h(object)h(method,)e(28)0 5164 y
Fo(__ror__\(\))h Ft(\(numeric)g(object)g(method\),)f(30)0
5264 y Fo(__rpow__\(\))h Ft(\(numeric)f(object)i(method\),)e(30)0
5363 y Fo(__rrshift__\(\))g Ft(\(numeric)h(object)g(method\),)g(30)1992
83 y Fo(__rshift__\(\))f Ft(\(numeric)g(object)i(method\),)e(30)1992
183 y Fo(__rsub__\(\))g Ft(\(numeric)h(object)h(method\),)e(30)1992
282 y Fo(__rtruediv__\(\))g Ft(\(numeric)g(object)i(method\),)e(30)1992
382 y Fo(__rxor__\(\))g Ft(\(numeric)h(object)h(method\),)e(30)1992
482 y Fo(__set__\(\))h Ft(\(object)g(method\),)f(25)1992
581 y Fo(__setattr__\(\))2158 681 y Ft(object)h(method,)g(24)2158
780 y(object)g(method,)g(24)1992 880 y Fo(__setitem__\(\))f
Ft(\(container)g(object)i(method\),)e(28)1992 980 y Fo
(__setslice__\(\))g Ft(\(sequence)g(object)i(method\),)e(29)1992
1079 y Fo(__slots__)h Ft(\(data)g(in)i(\),)f(26)1992
1179 y Fo(__str__\(\))f Ft(\(object)g(method\),)f(23)1992
1279 y Fo(__sub__\(\))h Ft(\(numeric)f(object)i(method\),)e(30)1992
1378 y Fo(__truediv__\(\))g Ft(\(numeric)g(object)i(method\),)e(30)1992
1478 y Fo(__unicode__\(\))g Ft(\(object)h(method\),)f(24)1992
1577 y Fo(__xor__\(\))h Ft(\(numeric)f(object)i(method\),)e(30)1992
1773 y Fm(A)1992 1896 y Fo(abs\(\))h Ft(\(b)n(uilt-in)h(function\),)d
(31)1992 1996 y(addition,)h(48)1992 2096 y(and)2158 2195
y(bit-wise,)i(48)1992 2295 y Fo(and)2158 2394 y Ft(operator)m(,)d(50)
1992 2494 y(anon)o(ymous)2158 2594 y(function,)h(50)1992
2693 y Fo(append\(\))h Ft(\(sequence)f(object)i(method\),)e(28)1992
2793 y(ar)o(gument)2158 2893 y(function,)g(16)1992 2992
y(arithmetic)2158 3092 y(con)m(v)o(ersion,)f(39)2158
3191 y(operation,)h(binary)-5 b(,)18 b(47)2158 3291 y(operation,)g
(unary)-5 b(,)18 b(47)1992 3391 y Fo(array)h Ft(\(standard)g(module\),)
f(16)1994 3490 y Fl(A)t(S)t(C)t(I)t(I)r Ft(,)j(2,)f(7,)g(8,)g(11,)g(15)
1992 3590 y Fo(assert)2158 3690 y Ft(statement,)f(53)1992
3789 y Fo(AssertionError)2158 3889 y Ft(e)o(xception,)f(54)1992
3988 y(assertions)2158 4088 y(deb)n(ugging,)f(53)1992
4188 y(assignment)2158 4287 y(attrib)n(ute,)i(54,)h(55)2158
4387 y(augmented,)d(55)2158 4487 y(class)k(attrib)n(ute,)e(19)2158
4586 y(class)i(instance)f(attrib)n(ute,)f(19)2158 4686
y(slicing,)g(55)2158 4786 y(statement,)g(16,)h(54)2158
4885 y(subscription,)e(55)2158 4985 y(tar)o(get)h(list,)i(54)1992
5084 y(atom,)e(39)1992 5184 y(attrib)n(ute,)g(14)2158
5284 y(assignment,)g(54,)g(55)2158 5383 y(assignment,)g(class,)i(19)p
0 5549 3901 4 v 0 5649 a Fp(86)3607 b(Inde)n(x)p eop
end
%%Page: 87 93
TeXDict begin 87 92 bop 166 83 a Ft(assignment,)19 b(class)i(instance,)
f(19)166 183 y(class,)h(19)166 282 y(class)g(instance,)f(19)166
382 y(deletion,)f(57)166 482 y(generic)g(special,)h(14)166
581 y(reference,)e(44)166 681 y(special,)i(14)0 780 y
Fo(AttributeError)166 880 y Ft(e)o(xception,)e(44)0 980
y(augmented)166 1079 y(assignment,)h(55)0 1272 y Fm(B)0
1396 y Ft(back-quotes,)f(23,)h(42)0 1495 y(backslash)h(character)m(,)e
(4)0 1595 y(backw)o(ard)166 1695 y(quotes,)h(23,)h(42)0
1794 y(binary)166 1894 y(arithmetic)f(operation,)g(47)166
1993 y(bit-wise)h(operation,)e(48)0 2093 y(binding)166
2193 y(global)h(name,)h(61)166 2292 y(name,)f(35,)h(54,)f(59,)h(60,)g
(67,)f(68)0 2392 y(bit-wise)166 2492 y(and,)g(48)166
2591 y(operation,)f(binary)-5 b(,)18 b(48)166 2691 y(operation,)g
(unary)-5 b(,)18 b(47)166 2790 y(or)m(,)h(48)166 2890
y(xor)m(,)g(48)0 2990 y(blank)g(line,)h(5)0 3089 y(block,)f(35)166
3189 y(code,)g(35)0 3289 y(BNF)-7 b(,)21 b(2,)f(39)0
3388 y(Boolean)166 3488 y(object,)f(14)166 3587 y(operation,)f(50)0
3687 y Fo(break)166 3787 y Ft(statement,)i(59,)f(64\22666)0
3886 y Fo(bsddb)h Ft(\(standard)e(module\),)h(16)0 3986
y(b)n(uilt-in)166 4086 y(method,)g(18)166 4185 y(module,)g(59)0
4285 y(b)n(uilt-in)h(function)166 4384 y(call,)g(46)166
4484 y(object,)f(18,)h(46)0 4584 y(b)n(uilt-in)g(method)166
4683 y(call,)g(46)166 4783 y(object,)f(18,)h(46)0 4883
y(byte,)f(15)0 4982 y(bytecode,)f(19)0 5177 y Fm(C)0
5300 y Ft(C,)j(8)166 5400 y(language,)d(14,)i(15,)f(18,)h(49)1992
83 y(call,)g(45)2158 183 y(b)n(uilt-in)f(function,)f(46)2158
282 y(b)n(uilt-in)h(method,)g(46)2158 382 y(class)i(instance,)e(46)2158
482 y(class)i(object,)e(18,)h(19,)f(46)2158 581 y(function,)f(16,)h(46)
2158 681 y(instance,)g(27,)h(46)2158 780 y(method,)e(46)2158
880 y(procedure,)f(53)2158 980 y(user)n(-de\002ned)h(function,)g(46)
1992 1079 y(callable)2158 1179 y(object,)h(16,)h(45)1992
1279 y(chaining)2158 1378 y(comparisons,)e(49)1992 1478
y(character)m(,)g(15,)h(44)1992 1577 y(character)f(set,)j(15)1992
1677 y Fo(chr\(\))e Ft(\(b)n(uilt-in)h(function\),)d(15)1992
1777 y(class,)j(21)2158 1876 y(attrib)n(ute,)f(19)2158
1976 y(attrib)n(ute)g(assignment,)g(19)2158 2076 y(constructor)m(,)e
(22)2158 2175 y(de\002nition,)h(57,)i(68)2158 2275 y(instance,)f(19)
2158 2374 y(name,)g(68)2158 2474 y(object,)g(18,)h(19,)f(46,)h(68)1992
2574 y Fo(class)2158 2673 y Ft(statement,)f(68)1992 2773
y(class)i(instance)2158 2873 y(attrib)n(ute,)e(19)2158
2972 y(attrib)n(ute)g(assignment,)g(19)2158 3072 y(call,)h(46)2158
3171 y(object,)f(18,)h(19,)f(46)1992 3271 y(class)i(object)2158
3371 y(call,)f(18,)f(19,)h(46)1992 3470 y(clause,)f(63)1992
3570 y Fo(clear\(\))g Ft(\(mapping)f(object)i(method\),)e(28)1992
3670 y Fo(close\(\))h Ft(\(generator)f(method\),)g(43)1992
3769 y Fo(cmp\(\))h Ft(\(b)n(uilt-in)h(function\),)d(24)1992
3869 y Fo(co_argcount)h Ft(\(code)h(object)h(attrib)n(ute\),)f(20)1992
3968 y Fo(co_cellvars)f Ft(\(code)h(object)h(attrib)n(ute\),)f(20)1992
4068 y Fo(co_code)g Ft(\(code)g(object)h(attrib)n(ute\),)f(20)1992
4168 y Fo(co_consts)g Ft(\(code)g(object)g(attrib)n(ute\),)h(20)1992
4267 y Fo(co_filename)e Ft(\(code)h(object)h(attrib)n(ute\),)f(20)1992
4367 y Fo(co_firstlineno)f Ft(\(code)h(object)g(attrib)n(ute\),)h(20)
1992 4467 y Fo(co_flags)f Ft(\(code)g(object)h(attrib)n(ute\),)f(20)
1992 4566 y Fo(co_freevars)f Ft(\(code)h(object)h(attrib)n(ute\),)f(20)
1992 4666 y Fo(co_lnotab)g Ft(\(code)g(object)g(attrib)n(ute\),)h(20)
1992 4765 y Fo(co_name)f Ft(\(code)g(object)h(attrib)n(ute\),)f(20)1992
4865 y Fo(co_names)g Ft(\(code)g(object)h(attrib)n(ute\),)f(20)1992
4965 y Fo(co_nlocals)f Ft(\(code)i(object)f(attrib)n(ute\),)g(20)1992
5064 y Fo(co_stacksize)f Ft(\(code)h(object)h(attrib)n(ute\),)f(20)1992
5164 y Fo(co_varnames)f Ft(\(code)h(object)h(attrib)n(ute\),)f(20)1992
5264 y(code)2158 5363 y(block,)g(35)p 0 5549 3901 4 v
0 5649 a Fp(Inde)n(x)3607 b(87)p eop end
%%Page: 88 94
TeXDict begin 88 93 bop 166 83 a Ft(object,)19 b(19)0
183 y(code)h(block,)e(59)0 282 y(comma,)h(40)166 382
y(trailing,)g(51,)h(57)0 482 y(command)e(line,)i(69)0
581 y(comment,)f(4)0 681 y(comparison,)f(49)166 780 y(string,)i(15)0
880 y(comparisons,)e(24)166 980 y(chaining,)g(49)0 1079
y Fo(compile\(\))h Ft(\(b)n(uilt-in)g(function\),)f(61)0
1179 y(comple)o(x)166 1279 y(literal,)i(9)166 1378 y(number)m(,)e(15)
166 1478 y(object,)h(15)0 1577 y Fo(complex\(\))g Ft(\(b)n(uilt-in)g
(function\),)f(31)0 1677 y(compound)166 1777 y(statement,)i(63)0
1876 y(comprehensions)166 1976 y(list,)h(40,)f(41)0 2076
y(Conditional)166 2175 y(e)o(xpression,)e(50)0 2275 y(constant,)h(7)0
2374 y(constructor)166 2474 y(class,)i(22)0 2574 y(container)m(,)d(14,)
i(19)0 2673 y(conte)o(xt)f(manager)m(,)f(33)0 2773 y
Fo(continue)166 2873 y Ft(statement,)i(59,)f(64\22666)0
2972 y(con)m(v)o(ersion)166 3072 y(arithmetic,)g(39)166
3171 y(string,)h(23,)f(42,)h(53)0 3271 y Fo(copy\(\))g
Ft(\(mapping)e(object)h(method\),)f(28)0 3371 y(coroutine,)g(42)0
3470 y Fo(count\(\))h Ft(\(sequence)g(object)h(method\),)e(28)0
3666 y Fm(D)0 3789 y Ft(dangling)166 3889 y(else,)j(63)0
3988 y(data,)f(13)166 4088 y(type,)g(14)166 4188 y(type,)g(immutable,)e
(40)0 4287 y(datum,)h(41)0 4387 y Fo(dbm)h Ft(\(standard)f(module\),)f
(16)0 4487 y(deb)n(ugging)166 4586 y(assertions,)i(53)0
4686 y(decimal)g(literal,)g(9)0 4786 y(DEDENT)g(tok)o(en,)f(5,)h(63)0
4885 y Fo(def)166 4985 y Ft(statement,)g(67)0 5084 y(def)o(ault)166
5184 y(parameter)f(v)n(alue,)g(67)0 5284 y(de\002nition)166
5383 y(class,)i(57,)e(68)2158 83 y(function,)f(57,)h(67)1992
183 y Fo(del)2158 282 y Ft(statement,)g(16,)h(22,)f(56)1992
382 y(delete,)g(16)1992 482 y(deletion)2158 581 y(attrib)n(ute,)g(57)
2158 681 y(tar)o(get,)g(56)2158 780 y(tar)o(get)g(list,)i(56)1992
880 y(delimiters,)e(11)1992 980 y(destructor)m(,)f(22,)h(55)1992
1079 y(dictionary)2158 1179 y(display)-5 b(,)19 b(41)2158
1279 y(object,)g(16,)h(19,)f(24,)h(41,)f(44,)h(55)1992
1378 y(display)2158 1478 y(dictionary)-5 b(,)17 b(41)2158
1577 y(list,)k(40)2158 1677 y(tuple,)e(40)1992 1777 y(di)n(vision,)g
(47)1992 1876 y Fo(divmod\(\))g Ft(\(b)n(uilt-in)g(function\),)f(30)
1992 1976 y(documentation)f(string,)i(20)1992 2172 y
Fm(E)1992 2295 y Ft(EBCDIC,)h(15)1992 2394 y Fo(elif)2158
2494 y Ft(k)o(e)o(yw)o(ord,)e(64)1992 2594 y(Ellipsis)2158
2693 y(object,)h(14)1992 2793 y(else)2158 2893 y(dangling,)f(63)1992
2992 y Fo(else)2158 3092 y Ft(k)o(e)o(yw)o(ord,)g(59,)h(64,)h(65)1992
3191 y(empty)2158 3291 y(list,)h(41)2158 3391 y(tuple,)e(15,)h(40)1992
3490 y(encodings,)e(4)1992 3590 y(en)m(vironment,)e(35)1992
3690 y(error)j(handling,)f(37)1992 3789 y(errors,)h(37)1992
3889 y(escape)h(sequence,)e(8)1992 3988 y Fo(eval\(\))h
Ft(\(b)n(uilt-in)g(function\),)f(61,)i(62,)f(70)1992
4088 y(e)n(v)n(aluation)2158 4188 y(order)m(,)f(51)1992
4287 y Fo(exc_info)h Ft(\(in)h(module)f(sys\),)h(20)1992
4387 y Fo(exc_traceback)e Ft(\(in)i(module)f(sys\),)h(20,)f(65)1992
4487 y Fo(exc_type)g Ft(\(in)h(module)f(sys\),)h(65)1992
4586 y Fo(exc_value)f Ft(\(in)h(module)e(sys\),)j(65)1992
4686 y Fo(except)2158 4786 y Ft(k)o(e)o(yw)o(ord,)d(65)1992
4885 y(e)o(xception,)g(36,)h(58)2158 4985 y Fo(AssertionError)p
Ft(,)e(54)2158 5084 y Fo(AttributeError)p Ft(,)g(44)2158
5184 y Fo(GeneratorExit)p Ft(,)h(43)2158 5284 y(handler)m(,)g(20)2158
5383 y Fo(ImportError)p Ft(,)g(59,)i(60)p 0 5549 3901
4 v 0 5649 a Fp(88)3607 b(Inde)n(x)p eop end
%%Page: 89 95
TeXDict begin 89 94 bop 166 83 a Fo(NameError)p Ft(,)19
b(40)166 183 y(raising,)h(58)166 282 y Fo(RuntimeError)p
Ft(,)e(57)166 382 y Fo(StopIteration)p Ft(,)g(42,)i(57)166
482 y Fo(SyntaxError)p Ft(,)f(59)166 581 y Fo(TypeError)p
Ft(,)g(47)166 681 y Fo(ValueError)p Ft(,)g(48)166 780
y Fo(ZeroDivisionError)p Ft(,)e(47)0 880 y(e)o(xception)h(handler)m(,)g
(37)0 980 y(e)o(xclusi)n(v)o(e)166 1079 y(or)m(,)h(48)0
1179 y Fo(exec)166 1279 y Ft(statement,)h(61,)f(62)0
1378 y Fo(execfile\(\))g Ft(\(b)n(uilt-in)g(function\),)f(61)0
1478 y(e)o(x)o(ecution)166 1577 y(frame,)h(35,)h(68)166
1677 y(restricted,)f(36)166 1777 y(stack,)h(20)0 1876
y(e)o(x)o(ecution)e(model,)h(35)0 1976 y(e)o(xpression,)f(39)166
2076 y(Conditional,)h(50)166 2175 y(generator)m(,)f(41)166
2275 y(lambda,)h(50)166 2374 y(list,)i(51,)f(53,)f(54)166
2474 y(statement,)h(53)166 2574 y(yield,)g(42)0 2673
y Fo(extend\(\))f Ft(\(sequence)g(object)h(method\),)e(28)0
2773 y(e)o(xtended)166 2873 y(slicing,)i(44)0 2972 y(e)o(xtended)e
(print)i(statement,)g(57)0 3072 y(e)o(xtended)e(slicing,)i(15)0
3171 y(e)o(xtension)166 3271 y(\002lename,)f(59)166 3371
y(module,)g(14)0 3553 y Fm(F)0 3677 y Fo(f_back)h Ft(\(frame)f(attrib)n
(ute\),)g(20)0 3776 y Fo(f_builtins)g Ft(\(frame)g(attrib)n(ute\),)g
(20)0 3876 y Fo(f_code)h Ft(\(frame)f(attrib)n(ute\),)g(20)0
3975 y Fo(f_exc_traceback)f Ft(\(frame)h(attrib)n(ute\),)g(20)0
4075 y Fo(f_exc_type)g Ft(\(frame)g(attrib)n(ute\),)g(20)0
4175 y Fo(f_exc_value)g Ft(\(frame)g(attrib)n(ute\),)g(20)0
4274 y Fo(f_globals)g Ft(\(frame)g(attrib)n(ute\),)g(20)0
4374 y Fo(f_lasti)g Ft(\(frame)g(attrib)n(ute\),)h(20)0
4474 y Fo(f_lineno)f Ft(\(frame)g(attrib)n(ute\),)g(20)0
4573 y Fo(f_locals)g Ft(\(frame)g(attrib)n(ute\),)g(20)0
4673 y Fo(f_restricted)g Ft(\(frame)g(attrib)n(ute\),)g(20)0
4772 y Fo(f_trace)g Ft(\(frame)g(attrib)n(ute\),)h(20)0
4872 y Fo(False)p Ft(,)g(14)0 4972 y(\002le)166 5071
y(object,)f(19,)h(70)0 5171 y(\002lename)166 5271 y(e)o(xtension,)f(59)
0 5370 y Fo(finally)2158 83 y Ft(k)o(e)o(yw)o(ord,)f(57,)h(59,)h(66)
1992 183 y Fo(float\(\))f Ft(\(b)n(uilt-in)g(function\),)f(31)1992
282 y(\003oating)h(point)2158 382 y(number)m(,)e(15)2158
482 y(object,)i(15)1992 581 y(\003oating)g(point)g(literal,)i(9)1992
681 y Fo(for)2158 780 y Ft(statement,)e(59,)h(64)1992
880 y(form)2158 980 y(lambda,)e(50,)i(68)1992 1079 y(frame)2158
1179 y(e)o(x)o(ecution,)d(35,)j(68)2158 1279 y(object,)f(20)1992
1378 y(free)2158 1478 y(v)n(ariable,)f(35,)i(56)1992
1577 y Fo(from)2158 1677 y Ft(k)o(e)o(yw)o(ord,)e(59,)h(60)2158
1777 y(statement,)g(35,)h(60)1992 1876 y(frozenset)2158
1976 y(object,)f(16)1992 2076 y Fo(func_closure)f Ft(\(function)g
(attrib)n(ute\),)h(17)1992 2175 y Fo(func_code)g Ft(\(function)f
(attrib)n(ute\),)h(17)1992 2275 y Fo(func_defaults)f
Ft(\(function)g(attrib)n(ute\),)h(17)1992 2374 y Fo(func_dict)g
Ft(\(function)f(attrib)n(ute\),)h(17)1992 2474 y Fo(func_doc)g
Ft(\(function)f(attrib)n(ute\),)h(17)1992 2574 y Fo(func_globals)f
Ft(\(function)g(attrib)n(ute\),)h(17)1992 2673 y(function)2158
2773 y(anon)o(ymous,)e(50)2158 2873 y(ar)o(gument,)g(16)2158
2972 y(call,)j(16,)f(46)2158 3072 y(call,)h(user)n(-de\002ned,)e(46)
2158 3171 y(de\002nition,)g(57,)i(67)2158 3271 y(generator)m(,)d(42,)j
(57)2158 3371 y(name,)f(67)2158 3470 y(object,)g(16,)h(18,)f(46,)h(67)
2158 3570 y(user)n(-de\002ned,)e(16)1992 3670 y(future)2158
3769 y(statement,)h(60)1992 3960 y Fm(G)1992 4084 y Ft(garbage)f
(collection,)h(13)1992 4183 y Fo(gdbm)h Ft(\(standard)e(module\),)g(16)
1992 4283 y(generator)2158 4382 y(e)o(xpression,)g(41)2158
4482 y(function,)g(18,)h(42,)h(57)2158 4582 y(iterator)m(,)f(18,)g(57)
2158 4681 y(object,)g(20,)h(41,)f(42)1992 4781 y Fo(GeneratorExit)2158
4881 y Ft(e)o(xception,)f(43)1992 4980 y(generic)2158
5080 y(special)i(attrib)n(ute,)f(14)1992 5179 y Fo(get\(\))g
Ft(\(mapping)f(object)i(method\),)e(28)1992 5279 y(global)2158
5379 y(name)h(binding,)f(61)p 0 5549 3901 4 v 0 5649
a Fp(Inde)n(x)3607 b(89)p eop end
%%Page: 90 96
TeXDict begin 90 95 bop 166 83 a Ft(namespace,)19 b(17)0
183 y Fo(global)166 282 y Ft(statement,)h(55,)f(56,)h(61)0
382 y Fo(globals\(\))f Ft(\(b)n(uilt-in)g(function\),)f(62)0
482 y(grammar)m(,)g(2)0 581 y(grouping,)f(5)0 775 y Fm(H)0
898 y Ft(handle)i(an)h(e)o(xception,)e(36)0 998 y(handler)166
1098 y(e)o(xception,)g(20)0 1197 y Fo(has_key\(\))h Ft(\(mapping)f
(object)i(method\),)e(28)0 1297 y Fo(hash\(\))i Ft(\(b)n(uilt-in)f
(function\),)f(24)0 1397 y(hash)i(character)m(,)e(4)0
1496 y Fo(hex\(\))i Ft(\(b)n(uilt-in)f(function\),)f(31)0
1596 y(he)o(xadecimal)g(literal,)i(9)0 1695 y(hierarchical)166
1795 y(module)f(names,)g(60)0 1895 y(hierarchy)166 1994
y(type,)h(14)0 2188 y Fm(I)0 2312 y Fo(id\(\))g Ft(\(b)n(uilt-in)f
(function\),)f(13)0 2411 y(identi\002er)m(,)h(6,)h(40)0
2511 y(identity)166 2610 y(test,)h(50)0 2710 y(identity)e(of)h(an)h
(object,)e(13)0 2810 y Fo(if)166 2909 y Ft(statement,)h(64)0
3009 y Fo(im_class)f Ft(\(method)g(attrib)n(ute\),)g(17)0
3109 y Fo(im_func)g Ft(\(method)g(attrib)n(ute\),)g(17)0
3208 y Fo(im_self)g Ft(\(method)g(attrib)n(ute\),)g(17)0
3308 y(imaginary)f(literal,)j(9)0 3407 y(immutable)166
3507 y(data)f(type,)g(40)166 3607 y(object,)f(15,)h(40,)g(41)0
3706 y(immutable)f(object,)g(13)0 3806 y(immutable)g(sequence)166
3906 y(object,)g(15)0 4005 y Fo(import)166 4105 y Ft(statement,)h(18,)f
(59)0 4204 y Fo(ImportError)166 4304 y Ft(e)o(xception,)f(59,)i(60)0
4404 y Fo(in)166 4503 y Ft(k)o(e)o(yw)o(ord,)e(64)166
4603 y(operator)m(,)g(50)0 4703 y(inclusi)n(v)o(e)166
4802 y(or)m(,)h(48)0 4902 y(INDENT)h(tok)o(en,)f(5)0
5001 y(indentation,)f(5)0 5101 y(inde)o(x)h(operation,)f(15)0
5201 y Fo(index\(\))h Ft(\(sequence)g(object)h(method\),)e(28)0
5300 y Fo(indices\(\))h Ft(\(slice)i(method\),)d(21)0
5400 y(inheritance,)g(68)1992 83 y(initialization)2158
183 y(module,)g(59)1992 282 y(input,)h(70)2158 382 y(ra)o(w)-5
b(,)19 b(70)1992 482 y Fo(input\(\))g Ft(\(b)n(uilt-in)g(function\),)f
(70)1992 581 y Fo(insert\(\))h Ft(\(sequence)f(object)i(method\),)e(28)
1992 681 y(instance)2158 780 y(call,)i(27,)f(46)2158
880 y(class,)h(19)2158 980 y(object,)f(18,)h(19,)f(46)1992
1079 y Fo(int\(\))g Ft(\(b)n(uilt-in)h(function\),)d(31)1992
1179 y(inte)o(ger)m(,)h(15)2158 1279 y(object,)h(14)2158
1378 y(representation,)e(15)1992 1478 y(inte)o(ger)i(literal,)h(9)1992
1577 y(interacti)n(v)o(e)e(mode,)h(69)1992 1677 y(internal)g(type,)g
(19)1992 1777 y(interpreter)m(,)e(69)1992 1876 y(in)m(v)o(ersion,)g(47)
1992 1976 y(in)m(v)n(ocation,)h(16)1992 2076 y Fo(is)2158
2175 y Ft(operator)m(,)f(50)1992 2275 y Fo(is)49 b(not)2158
2374 y Ft(operator)m(,)17 b(50)1992 2474 y(item)2158
2574 y(sequence,)h(44)2158 2673 y(string,)h(44)1992 2773
y(item)h(selection,)g(15)1992 2873 y Fo(items\(\))f Ft(\(mapping)f
(object)i(method\),)e(28)1992 2972 y Fo(iteritems\(\))g
Ft(\(mapping)g(object)i(method\),)e(28)1992 3072 y Fo(iterkeys\(\))g
Ft(\(mapping)g(object)i(method\),)e(28)1992 3171 y Fo(itervalues\(\))g
Ft(\(mapping)g(object)i(method\),)e(28)1992 3364 y Fm(J)1992
3487 y Ft(Ja)n(v)n(a)2158 3587 y(language,)g(15)1992
3779 y Fm(K)1992 3902 y Ft(k)o(e)o(y)-5 b(,)18 b(41)1992
4002 y(k)o(e)o(y/datum)g(pair)m(,)h(41)1992 4101 y Fo(keys\(\))g
Ft(\(mapping)f(object)i(method\),)e(28)1992 4201 y(k)o(e)o(yw)o(ord,)g
(7)2158 4301 y Fo(elif)p Ft(,)h(64)2158 4400 y Fo(else)p
Ft(,)g(59,)h(64,)f(65)2158 4500 y Fo(except)p Ft(,)g(65)2158
4599 y Fo(finally)p Ft(,)g(57,)g(59,)h(66)2158 4699 y
Fo(from)p Ft(,)f(59,)h(60)2158 4799 y Fo(in)p Ft(,)g(64)2158
4898 y Fo(yield)p Ft(,)f(42)1992 5077 y Fm(L)1992 5201
y Ft(lambda)2158 5300 y(e)o(xpression,)f(50)2158 5400
y(form,)g(50,)i(68)p 0 5549 3901 4 v 0 5649 a Fp(90)3607
b(Inde)n(x)p eop end
%%Page: 91 97
TeXDict begin 91 96 bop 0 83 a Ft(language)166 183 y(C,)21
b(14,)e(15,)h(18,)g(49)166 282 y(Ja)n(v)n(a,)g(15)166
382 y(P)o(ascal,)g(64)0 482 y Fo(last_traceback)e Ft(\(in)i(module)f
(sys\),)h(20)0 581 y(leading)f(whitespace,)h(5)0 681
y Fo(len\(\))g Ft(\(b)n(uilt-in)f(function\),)f(15,)h(16,)h(28)0
780 y(le)o(xical)g(analysis,)g(3)0 880 y(le)o(xical)g(de\002nitions,)f
(2)0 980 y(line)h(continuation,)e(4)0 1079 y(line)i(joining,)f(3,)h(4)0
1179 y(line)g(structure,)f(3)0 1279 y(list)166 1378 y(assignment,)g
(tar)o(get,)g(54)166 1478 y(comprehensions,)e(40,)j(41)166
1577 y(deletion)f(tar)o(get,)g(56)166 1677 y(display)-5
b(,)19 b(40)166 1777 y(empty)-5 b(,)19 b(41)166 1876
y(e)o(xpression,)f(51,)i(53,)f(54)166 1976 y(object,)g(16,)h(41,)g(44,)
f(55)166 2076 y(tar)o(get,)g(54,)h(64)0 2175 y(literal,)g(7,)g(40)0
2275 y Fo(locals\(\))f Ft(\(b)n(uilt-in)g(function\),)f(62)0
2374 y(logical)i(line,)g(3)0 2474 y Fo(long\(\))g Ft(\(b)n(uilt-in)f
(function\),)f(31)0 2574 y(long)h(inte)o(ger)166 2673
y(object,)g(14)0 2773 y(long)g(inte)o(ger)g(literal,)i(9)0
2873 y(loop)166 2972 y(o)o(v)o(er)e(mutable)g(sequence,)g(65)166
3072 y(statement,)h(59,)f(64)0 3171 y(loop)g(control)166
3271 y(tar)o(get,)g(59)0 3467 y Fm(M)0 3590 y Fo(makefile\(\))g
Ft(\(sock)o(et)h(method\),)e(19)0 3690 y(mangling)166
3789 y(name,)h(40)0 3889 y(mapping)166 3988 y(object,)g(16,)h(19,)g
(44,)f(55)0 4088 y(membership)166 4188 y(test,)i(50)0
4287 y(method)166 4387 y(b)n(uilt-in,)e(18)166 4487 y(call,)h(46)166
4586 y(object,)f(17,)h(18,)g(46)166 4686 y(user)n(-de\002ned,)e(17)0
4786 y(minus,)h(47)0 4885 y(module)166 4985 y(b)n(uilt-in,)g(59)166
5084 y(e)o(xtension,)g(14)166 5184 y(importing,)f(59)166
5284 y(initialization,)h(59)166 5383 y(name,)g(59)2158
83 y(names,)g(hierarchical,)g(60)2158 183 y(namespace,)f(18)2158
282 y(object,)h(18,)h(44)2158 382 y(search)f(path,)h(59)2158
482 y(user)n(-de\002ned,)e(59)1992 581 y Fo(modules)h
Ft(\(in)h(module)f(sys\),)h(59)1992 681 y(modulo,)e(48)1992
780 y(multiplication,)g(47)1992 880 y(mutable)2158 980
y(object,)h(16,)h(54,)f(55)1992 1079 y(mutable)g(object,)g(13)1992
1179 y(mutable)g(sequence)2158 1279 y(loop)g(o)o(v)o(er)m(,)f(65)2158
1378 y(object,)h(16)1992 1574 y Fm(N)1992 1697 y Ft(name,)g(6,)h(35,)f
(40)2158 1797 y(binding,)f(35,)h(54,)h(59,)f(60,)h(67,)f(68)2158
1896 y(binding,)f(global,)h(61)2158 1996 y(class,)h(68)2158
2096 y(function,)e(67)2158 2195 y(mangling,)g(40)2158
2295 y(module,)g(59)2158 2394 y(rebinding,)f(54)2158
2494 y(unbinding,)g(56)1992 2594 y Fo(NameError)2158
2693 y Ft(e)o(xception,)h(40)1992 2793 y Fo(NameError)h
Ft(\(b)n(uilt-in)g(e)o(xception\),)f(35)1992 2893 y(names)2158
2992 y(hierarchical)g(module,)h(60)2158 3092 y(pri)n(v)n(ate,)f(40)1992
3191 y(namespace,)g(35)2158 3291 y(global,)h(17)2158
3391 y(module,)f(18)1992 3490 y(ne)o(gation,)f(47)1992
3590 y(ne)n(wline)2158 3690 y(suppression,)h(57)1992
3789 y(NEWLINE)h(tok)o(en,)h(3,)g(63)1992 3889 y Fo(next\(\))f
Ft(\(generator)f(method\),)g(42)1992 3988 y(None)2158
4088 y(object,)h(14,)h(53)1992 4188 y Fo(not)2158 4287
y Ft(operator)m(,)d(50)1992 4387 y Fo(not)49 b(in)2158
4487 y Ft(operator)m(,)17 b(50)1992 4586 y(notation,)h(2)1992
4686 y(NotImplemented)2158 4786 y(object,)h(14)1992 4885
y(null)2158 4985 y(operation,)f(56)1992 5084 y(number)m(,)f(9)2158
5184 y(comple)o(x,)h(15)2158 5284 y(\003oating)h(point,)g(15)1992
5383 y(numeric)p 0 5549 3901 4 v 0 5649 a Fp(Inde)n(x)3607
b(91)p eop end
%%Page: 92 98
TeXDict begin 92 97 bop 166 83 a Ft(object,)19 b(14,)h(19)0
183 y(numeric)f(literal,)h(9)0 374 y Fm(O)0 497 y Ft(object,)f(13)166
597 y(Boolean,)g(14)166 696 y(b)n(uilt-in)h(function,)e(18,)h(46)166
796 y(b)n(uilt-in)h(method,)e(18,)i(46)166 896 y(callable,)g(16,)f(45)
166 995 y(class,)i(18,)e(19,)h(46,)g(68)166 1095 y(class)h(instance,)f
(18,)f(19,)h(46)166 1194 y(code,)f(19)166 1294 y(comple)o(x,)f(15)166
1394 y(dictionary)-5 b(,)18 b(16,)h(19,)h(24,)f(41,)h(44,)f(55)166
1493 y(Ellipsis,)i(14)166 1593 y(\002le,)g(19,)e(70)166
1693 y(\003oating)h(point,)f(15)166 1792 y(frame,)g(20)166
1892 y(frozenset,)g(16)166 1991 y(function,)f(16,)i(18,)f(46,)h(67)166
2091 y(generator)m(,)e(20,)h(41,)h(42)166 2191 y(immutable,)f(15,)g
(40,)h(41)166 2290 y(immutable)f(sequence,)g(15)166 2390
y(instance,)h(18,)f(19,)h(46)166 2490 y(inte)o(ger)m(,)f(14)166
2589 y(list,)i(16,)f(41,)f(44,)h(55)166 2689 y(long)f(inte)o(ger)m(,)g
(14)166 2788 y(mapping,)f(16,)i(19,)f(44,)h(55)166 2888
y(method,)f(17,)g(18,)h(46)166 2988 y(module,)f(18,)g(44)166
3087 y(mutable,)g(16,)h(54,)f(55)166 3187 y(mutable)g(sequence,)g(16)
166 3287 y(None,)g(14,)h(53)166 3386 y(NotImplemented,)d(14)166
3486 y(numeric,)i(14,)g(19)166 3585 y(plain)h(inte)o(ger)m(,)e(14)166
3685 y(recursi)n(v)o(e,)h(42)166 3785 y(sequence,)g(15,)g(19,)h(44,)f
(50,)h(55,)f(64)166 3884 y(set,)i(16)166 3984 y(set)g(type,)f(16)166
4084 y(slice,)h(28)166 4183 y(string,)f(15,)f(44)166
4283 y(traceback,)g(20,)g(58,)h(65)166 4382 y(tuple,)g(15,)f(44,)h(51)
166 4482 y(unicode,)e(15)166 4582 y(user)n(-de\002ned)h(function,)f
(16,)h(46,)h(67)166 4681 y(user)n(-de\002ned)f(method,)f(17)0
4781 y Fo(oct\(\))i Ft(\(b)n(uilt-in)f(function\),)f(31)0
4881 y(octal)i(literal,)g(9)0 4980 y Fo(open\(\))g Ft(\(b)n(uilt-in)f
(function\),)f(19)0 5080 y(operation)166 5179 y(binary)h(arithmetic,)g
(47)166 5279 y(binary)g(bit-wise,)h(48)166 5379 y(Boolean,)f(50)2158
83 y(null,)g(56)2158 183 y(shifting,)g(48)2158 282 y(unary)f
(arithmetic,)i(47)2158 382 y(unary)e(bit-wise,)i(47)1992
482 y(operator)2158 581 y Fo(and)p Ft(,)g(50)2158 681
y Fo(in)p Ft(,)g(50)2158 780 y Fo(is)p Ft(,)g(50)2158
880 y Fo(is)49 b(not)p Ft(,)20 b(50)2158 980 y Fo(not)p
Ft(,)g(50)2158 1079 y Fo(not)49 b(in)p Ft(,)20 b(50)2158
1179 y Fo(or)p Ft(,)g(50)2158 1279 y(o)o(v)o(erloading,)c(21)2158
1378 y(precedence,)h(51)1992 1478 y(operators,)h(11)1992
1577 y(or)2158 1677 y(bit-wise,)i(48)2158 1777 y(e)o(xclusi)n(v)o(e,)e
(48)2158 1876 y(inclusi)n(v)o(e,)h(48)1992 1976 y Fo(or)2158
2076 y Ft(operator)m(,)e(50)1992 2175 y Fo(ord\(\))i
Ft(\(b)n(uilt-in)h(function\),)d(15)1992 2275 y(order)2158
2374 y(e)n(v)n(aluation,)h(51)1992 2474 y(output,)g(53,)i(57)2158
2574 y(standard,)e(53,)i(57)1992 2673 y Fo(OverflowError)e
Ft(\(b)n(uilt-in)h(e)o(xception\),)f(14)1992 2773 y(o)o(v)o(erloading)
2158 2873 y(operator)m(,)f(21)1992 3068 y Fm(P)1992 3191
y Ft(packages,)h(60)1992 3291 y(parameter)2158 3391 y(v)n(alue,)h(def)o
(ault,)g(67)1992 3490 y(parenthesized)f(form,)h(40)1992
3590 y(parser)m(,)g(3)1992 3690 y(P)o(ascal)2158 3789
y(language,)f(64)1992 3889 y Fo(pass)2158 3988 y Ft(statement,)h(56)
1992 4088 y(path)2158 4188 y(module)f(search,)i(59)1992
4287 y(physical)f(line,)h(3,)g(4,)g(8)1992 4387 y(plain)f(inte)o(ger)
2158 4487 y(object,)g(14)1992 4586 y(plain)g(inte)o(ger)g(literal,)i(9)
1992 4686 y(plus,)e(47)1992 4786 y Fo(pop\(\))2158 4885
y Ft(mapping)f(object)i(method,)e(28)2158 4985 y(sequence)h(object)g
(method,)g(28)1992 5084 y Fo(popen\(\))g Ft(\(in)h(module)f(os\),)h(19)
1992 5184 y Fo(popitem\(\))f Ft(\(mapping)f(object)h(method\),)f(28)
1992 5284 y Fo(pow\(\))h Ft(\(b)n(uilt-in)h(function\),)d(30,)j(31)1992
5383 y(precedence)p 0 5549 3901 4 v 0 5649 a Fp(92)3607
b(Inde)n(x)p eop end
%%Page: 93 99
TeXDict begin 93 98 bop 166 83 a Ft(operator)m(,)18 b(51)0
183 y(primary)-5 b(,)18 b(43)0 282 y Fo(print)166 382
y Ft(statement,)i(23,)f(57)0 482 y(pri)n(v)n(ate)166
581 y(names,)h(40)0 681 y(procedure)166 780 y(call,)g(53)0
880 y(program,)e(69)0 980 y(Python)h(Enhancement)f(Proposals)166
1079 y(PEP)j(0255,)d(58)166 1179 y(PEP)j(0342,)d(43,)i(58)166
1279 y(PEP)h(0343,)d(33,)i(66)0 1467 y Fm(Q)0 1590 y
Ft(quotes)166 1690 y(backw)o(ard,)e(23,)i(42)166 1790
y(re)n(v)o(erse,)f(23,)g(42)0 1970 y Fm(R)0 2093 y Fo(raise)166
2193 y Ft(statement,)h(58)0 2292 y(raise)g(an)h(e)o(xception,)d(36)0
2392 y(raising)166 2492 y(e)o(xception,)g(58)0 2591 y
Fo(range\(\))h Ft(\(b)n(uilt-in)h(function\),)e(64)0
2691 y(ra)o(w)i(input,)f(70)0 2790 y(ra)o(w)h(string,)g(8)0
2890 y Fo(raw_input\(\))f Ft(\(b)n(uilt-in)g(function\),)f(70)0
2990 y Fo(readline\(\))h Ft(\(\002le)h(method\),)f(70)0
3089 y(rebinding)166 3189 y(name,)g(54)0 3289 y(recursi)n(v)o(e)166
3388 y(object,)g(42)0 3488 y(reference)166 3587 y(attrib)n(ute,)h(44)0
3687 y(reference)f(counting,)f(13)0 3787 y Fo(remove\(\))h
Ft(\(sequence)g(object)h(method\),)e(28)0 3886 y Fo(repr\(\))i
Ft(\(b)n(uilt-in)f(function\),)f(23,)h(42,)h(53)0 3986
y(representation)166 4086 y(inte)o(ger)m(,)f(15)0 4185
y(reserv)o(ed)g(w)o(ord,)g(7)0 4285 y(restricted)166
4384 y(e)o(x)o(ecution,)f(36)0 4484 y Fo(return)166 4584
y Ft(statement,)i(57,)f(65,)h(66)0 4683 y(re)n(v)o(erse)166
4783 y(quotes,)f(23,)h(42)0 4883 y Fo(reverse\(\))f Ft(\(sequence)g
(object)g(method\),)g(28)0 4982 y Fo(RuntimeError)166
5082 y Ft(e)o(xception,)f(57)0 5277 y Fm(S)0 5400 y Ft(scope,)i(35)1992
83 y(search)2158 183 y(path,)f(module,)g(59)1992 282
y Fo(send\(\))g Ft(\(generator)f(method\),)g(42)1992
382 y(sequence)2158 482 y(item,)i(44)2158 581 y(object,)f(15,)h(19,)f
(44,)h(50,)f(55,)h(64)1992 681 y(set)2158 780 y(object,)f(16)1992
880 y(set)i(type)2158 980 y(object,)e(16)1992 1079 y
Fo(setdefault\(\))f Ft(\(mapping)g(object)i(method\),)e(28)1992
1179 y(shifting)2158 1279 y(operation,)g(48)1992 1378
y(simple)2158 1478 y(statement,)h(53)1992 1577 y(singleton)2158
1677 y(tuple,)g(15)1992 1777 y(slice,)h(44)2158 1876
y(object,)f(28)1992 1976 y Fo(slice\(\))g Ft(\(b)n(uilt-in)g
(function\),)f(20)1992 2076 y(slicing,)h(15,)h(16,)g(44)2158
2175 y(assignment,)f(55)2158 2275 y(e)o(xtended,)f(44)1992
2374 y Fo(sort\(\))h Ft(\(sequence)g(object)g(method\),)g(28)1992
2474 y(source)g(character)g(set,)i(4)1992 2574 y(space,)e(5)1992
2673 y(special)2158 2773 y(attrib)n(ute,)g(14)2158 2873
y(attrib)n(ute,)g(generic,)g(14)1992 2972 y(stack)2158
3072 y(e)o(x)o(ecution,)e(20)2158 3171 y(trace,)i(20)1992
3271 y(standard)2158 3371 y(output,)f(53,)i(57)1992 3470
y(Standard)e(C,)j(8)1992 3570 y(standard)e(input,)g(69)1992
3670 y Fo(start)g Ft(\(slice)i(object)f(attrib)n(ute\),)f(21,)g(45)1992
3769 y(statement)2158 3869 y Fo(assert)p Ft(,)g(53)2158
3968 y(assignment,)g(16,)g(54)2158 4068 y(assignment,)g(augmented,)e
(55)2158 4168 y Fo(break)p Ft(,)i(59,)h(64\22666)2158
4267 y Fo(class)p Ft(,)f(68)2158 4367 y(compound,)e(63)2158
4467 y Fo(continue)p Ft(,)i(59,)g(64\22666)2158 4566
y Fo(def)p Ft(,)h(67)2158 4666 y Fo(del)p Ft(,)g(16,)f(22,)h(56)2158
4765 y Fo(exec)p Ft(,)f(61,)h(62)2158 4865 y(e)o(xpression,)e(53)2158
4965 y Fo(for)p Ft(,)i(59,)f(64)2158 5064 y Fo(from)p
Ft(,)g(35,)h(60)2158 5164 y(future,)e(60)2158 5264 y
Fo(global)p Ft(,)h(55,)g(56,)h(61)2158 5363 y Fo(if)p
Ft(,)g(64)p 0 5549 3901 4 v 0 5649 a Fp(Inde)n(x)3607
b(93)p eop end
%%Page: 94 100
TeXDict begin 94 99 bop 166 83 a Fo(import)p Ft(,)19
b(18,)h(59)166 183 y(loop,)f(59,)h(64)166 282 y Fo(pass)p
Ft(,)g(56)166 382 y Fo(print)p Ft(,)g(23,)f(57)166 482
y Fo(raise)p Ft(,)h(58)166 581 y Fo(return)p Ft(,)f(57,)h(65,)g(66)166
681 y(simple,)g(53)166 780 y Fo(try)p Ft(,)g(20,)g(65)166
880 y Fo(while)p Ft(,)g(59,)f(64)166 980 y Fo(with)p
Ft(,)h(33,)f(66)166 1079 y Fo(yield)p Ft(,)h(57)0 1179
y(statement)g(grouping,)d(5)0 1279 y Fo(stderr)j Ft(\(in)g(module)e
(sys\),)j(19)0 1378 y Fo(stdin)f Ft(\(in)g(module)f(sys\),)h(19)0
1478 y(stdio,)g(19)0 1577 y Fo(stdout)g Ft(\(in)g(module)e(sys\),)j
(19,)e(57)0 1677 y Fo(step)h Ft(\(slice)h(object)e(attrib)n(ute\),)g
(21,)h(45)0 1777 y Fo(stop)g Ft(\(slice)h(object)e(attrib)n(ute\),)g
(21,)h(45)0 1876 y Fo(StopIteration)166 1976 y Ft(e)o(xception,)e(42,)i
(57)0 2076 y Fo(str\(\))g Ft(\(b)n(uilt-in)f(function\),)f(23,)h(42)0
2175 y(string)166 2275 y(comparison,)f(15)166 2374 y(con)m(v)o(ersion,)
f(23,)j(42,)f(53)166 2474 y(item,)h(44)166 2574 y(object,)f(15,)h(44)
166 2673 y(Unicode,)f(8)0 2773 y(string)h(literal,)g(7)0
2873 y(subscription,)e(15,)i(16,)f(44)166 2972 y(assignment,)g(55)0
3072 y(subtraction,)f(48)0 3171 y(suite,)i(63)0 3271
y(suppression)166 3371 y(ne)n(wline,)f(57)0 3470 y(syntax,)g(2,)h(39)0
3570 y Fo(SyntaxError)166 3670 y Ft(e)o(xception,)e(59)0
3769 y Fo(sys)i Ft(\(b)n(uilt-in)f(module\),)g(57,)g(59,)h(65,)f(69)0
3869 y Fo(sys.exc_info)p Ft(,)f(20)0 3968 y Fo(sys.exc_traceback)p
Ft(,)f(20)0 4068 y Fo(sys.last_traceback)p Ft(,)g(20)0
4168 y Fo(sys.modules)p Ft(,)h(59)0 4267 y Fo(sys.stderr)p
Ft(,)h(19)0 4367 y Fo(sys.stdin)p Ft(,)g(19)0 4467 y
Fo(sys.stdout)p Ft(,)g(19)0 4566 y Fo(SystemExit)g Ft(\(b)n(uilt-in)g
(e)o(xception\),)f(37)0 4762 y Fm(T)0 4885 y Ft(tab,)i(5)0
4985 y(tar)o(get,)f(54)166 5084 y(deletion,)g(56)166
5184 y(list,)i(54,)f(64)166 5284 y(list)h(assignment,)e(54)166
5383 y(list,)i(deletion,)e(56)2158 83 y(loop)g(control,)g(59)1992
183 y Fo(tb_frame)g Ft(\(traceback)f(attrib)n(ute\),)h(20)1992
282 y Fo(tb_lasti)g Ft(\(traceback)f(attrib)n(ute\),)h(20)1992
382 y Fo(tb_lineno)g Ft(\(traceback)f(attrib)n(ute\),)h(20)1992
482 y Fo(tb_next)g Ft(\(traceback)f(attrib)n(ute\),)i(20)1992
581 y(termination)e(model,)h(37)1992 681 y(test)2158
780 y(identity)-5 b(,)18 b(50)2158 880 y(membership,)g(50)1992
980 y Fo(throw\(\))h Ft(\(generator)f(method\),)g(43)1992
1079 y(tok)o(en,)h(3)1992 1179 y(trace)2158 1279 y(stack,)h(20)1992
1378 y(traceback)2158 1478 y(object,)f(20,)h(58,)f(65)1992
1577 y(trailing)2158 1677 y(comma,)f(51,)i(57)1992 1777
y(triple-quoted)d(string,)j(8)1992 1876 y Fo(True)p Ft(,)f(14)1992
1976 y Fo(try)2158 2076 y Ft(statement,)g(20,)h(65)1992
2175 y(tuple)2158 2275 y(display)-5 b(,)19 b(40)2158
2374 y(empty)-5 b(,)18 b(15,)i(40)2158 2474 y(object,)f(15,)h(44,)f(51)
2158 2574 y(singleton,)g(15)1992 2673 y(type,)g(14)2158
2773 y(data,)g(14)2158 2873 y(hierarchy)-5 b(,)17 b(14)2158
2972 y(immutable)h(data,)i(40)1992 3072 y Fo(type\(\))f
Ft(\(b)n(uilt-in)g(function\),)f(13)1992 3171 y(type)h(of)h(an)g
(object,)g(13)1992 3271 y Fo(TypeError)2158 3371 y Ft(e)o(xception,)e
(47)1992 3470 y(types,)h(internal,)g(19)1992 3666 y Fm(U)1992
3789 y Ft(unary)2158 3889 y(arithmetic)g(operation,)f(47)2158
3988 y(bit-wise)i(operation,)e(47)1992 4088 y(unbinding)2158
4188 y(name,)h(56)1992 4287 y Fo(UnboundLocalError)p
Ft(,)e(35)1992 4387 y Fo(unichr\(\))i Ft(\(b)n(uilt-in)g(function\),)f
(15)1992 4487 y(Unicode,)g(15)1992 4586 y(unicode)2158
4686 y(object,)h(15)1992 4786 y Fo(unicode\(\))g Ft(\(b)n(uilt-in)g
(function\),)f(15,)h(24)1992 4885 y(Unicode)g(Consortium,)f(8)1992
4985 y(UNIX,)h(69)1992 5084 y(unreachable)e(object,)j(13)1992
5184 y(unrecognized)d(escape)j(sequence,)e(9)1992 5284
y Fo(update\(\))h Ft(\(mapping)f(object)h(method\),)g(28)1992
5383 y(user)n(-de\002ned)p 0 5549 3901 4 v 0 5649 a Fp(94)3607
b(Inde)n(x)p eop end
%%Page: 95 101
TeXDict begin 95 100 bop 166 83 a Ft(function,)18 b(16)166
183 y(function)h(call,)h(46)166 282 y(method,)f(17)166
382 y(module,)g(59)0 482 y(user)n(-de\002ned)f(function)166
581 y(object,)h(16,)h(46,)g(67)0 681 y(user)n(-de\002ned)e(method)166
780 y(object,)h(17)0 976 y Fm(V)0 1099 y Ft(v)n(alue)166
1199 y(def)o(ault)h(parameter)m(,)e(67)0 1299 y(v)n(alue)i(of)f(an)i
(object,)e(13)0 1398 y Fo(ValueError)166 1498 y Ft(e)o(xception,)f(48)0
1597 y(v)n(alues)166 1697 y(writing,)h(53,)h(57)0 1797
y Fo(values\(\))f Ft(\(mapping)f(object)i(method\),)e(28)0
1896 y(v)n(ariable)166 1996 y(free,)i(35,)f(56)0 2179
y Fm(W)0 2302 y Fo(while)166 2401 y Ft(statement,)h(59,)f(64)0
2501 y(whitespace,)g(5)0 2601 y Fo(with)166 2700 y Ft(statement,)h(33,)
f(66)0 2800 y(writing)166 2900 y(v)n(alues,)h(53,)f(57)0
3082 y Fm(X)0 3206 y Ft(xor)166 3305 y(bit-wise,)h(48)0
3488 y Fm(Y)0 3611 y Ft(yield)166 3711 y(e)o(xpression,)e(42)0
3810 y Fo(yield)166 3910 y Ft(k)o(e)o(yw)o(ord,)g(42)166
4010 y(statement,)i(57)0 4192 y Fm(Z)0 4315 y Fo(ZeroDivisionError)166
4415 y Ft(e)o(xception,)e(47)p 0 5549 3901 4 v 0 5649
a Fp(Inde)n(x)3607 b(95)p eop end
%%Trailer
userdict /end-hook known{end-hook}if
%%EOF