Files
cpython/Doc/ref/ref3.doc

469 lines
99 KiB
Plaintext
Raw Normal View History

<MakerFile 5.0Y>

Aa<61>ow<00>)<03>ff <03><03><03><03><03><03><03><03><03>HH $<04>@d H?^<5E>L<><00><><00><><00><>ff@ <00><00><00><00><>
<EFBFBD>
<EFBFBD>
<EFBFBD><><><><01>
<EFBFBD><><><><>d<04> <09>Footnote
TableFootnote*<2A><>*<2A><>.\t.\t/ - <20> <20>:;,.<2E>!?tpd2
`/
b <()),AttributeErrorVona[i:jbytecodecmp co_argcountco_code co_consts co_filenameco_flagsco_names
co_nlocals co_varnamescodehackdelattrdelitemdictdocf_back
f_builtinsf_code f_globalsf_lastif_linenof_localsf_owner f_restrictedf_trace func_code
func_defaults func_globals func_namegetattrgetitem getlinenogetsliceglobalsi:jim_classim_funcim_selfinitk:l
1997-05-08 23:39:55 +00:00
lowerboundpathnamereprsetattrsetitemstdiostrtb_frametb_lasti tb_linenotb_nexte traceback
upperbound x(arguments)<04>==<3D>A<>CA<>TA   EquationVariables<1D><08> <0C> T"<19><08><08><02><19><08><08>
<19><08><08><02><19> <08><19> <08><19> <08><19> <08><19> <08>tno<19> <08>Foo<19> <08><02><><19> <08><19> <08>\t<19> <08> - <19>
<08>.<2E>!<19> <08>2<19> <08><19>
<08>
<19> <08><19> <08>),
<08>teE <08> <08>yte <08>  <08>nt <08>  <08> " <08>me% <08>s& <08>
co' <08> co- <08>/ <08>de< <08>eli? <08>t@ <08>ackA <08>insQ !<08> f_6 "<08>f_7 #<08>_li<1B> $<08>oca %<08>erO &<08>ictD '<08>ce<1B> (<08>de<1B> )<08>fauJ *<08>c_gR +<08>uncp ,<08>etaS -<08>iter .<08>nent /<08>iceu 0<08>v 1<08>claw 2<08>nc 3<08><1D> 4<08>
<13> 5<08>d<14> 6<08>re<14> 7<08>tr<14> 8<08><14> 9<08>tr5 :<08>e6 ;<08> tb7 <<08>8 =<08>rac9 ><08>ppe: ?<08>(ar; @<08><04>=< A<08>C= B<08>T> C<08>Y D<08>7 E<08>] F<08>^ G<08> _ H<08>` I<08>a J<08>b K<08>c L<08>d M<08>ione N<08>f O<08><14> P<08>X Q<08><02> <0C>Y R<08><02><08>Z S<08><02><08>[ U<08><02><08>\ V<08><08><14> W <09><08><14> X <09><08><14> Y <09><08><14> Z <09><08><14> [ <09><08><14> \ <09><08>b ]<08><08>h ^<08><08>i _<08> <08>j `<08>
<08>m a<08> <08>n b<08> <08><1A> c<08>
<08><1A> d <09><08><1A> e <09><08><1A> f<08><08><1A> g <09><08><1A> h <09><08><1A> i <09><08><1A> j <09><08><1A> k<08><08><1A> l<08><08><1A> m<08><08><1A> n<08><08><1A> o<08><08><1A> p <08><1A> q <08><1A> r <08><1A> s <08><1A> t <08><1A> u <08><1A> v  <08><1A> w !<08><1A> x "<08><1A> y #<08><1A> z
$<08><1A> { %<08><1A> | &<08><1A> }
'<08><1A> ~ (<08><1A>  )<08><1A> <09> *<08><1A> <09> +<08><1A> <09> ,<08><1A> <09> -<08> <09> .<08> <09> /<08> <09> 0<08> <09> 1<08> <09> 2<08>
<09> 3<08> <09> 4<08> <09> 5<08> <09> 6<08> <09> 7<08> <09> 8<08> <09> 9<08> <09> :<08> <09> <09>;<08> <09> <09><<08> <09> !=<08>> <09> "><08>? <09> <09>?<08>A <09> <09>@<08>C <09> #A<08>D <09> $B<08>E <09> %C<08>F <09> &D<08>G <09> 'E<08>H <09> (F<08>O <09> )G<08>R <09> *H<08>S <09> +I<08>T <09> ,J<08>W <09> -K<08>X <09> .L<08>Y <09> /M<08>\ <09> 0N<08>] <09> 1O<08>^ <09> 2P<08>c <09> 3Q<08>e <09> <09>R<08>f <09> <09>S<08>g <09> 4U<08>h <09> 5V<08>i <09> 6W <09>j <09> 7X <09>m <09> 8Y <09>n <09> 9Z <09>q <09> :[ <09>r <09> ;\ <09>s <09> <]<08>t <09> =^<08>u <09> >_<08>v <09> ?`<08>w <09> @a<08>x <09> Ab<08><1D> <09> Bc<08><1D> <09> <09>d <09>} <09> De <09><1B> <09> Ef<08><1B> <09> Fg <09><1B> <09> Gh <09><1B> <09> Hi <09>z <09> Ij <09><1B> <09> Jk<08><1B> <09> Kl<08><1B> <09> Lm<08><1B> <09> Mn<08><1B> <09> No<08><1B> <09> Op <1B> <09> Pq <1B> <09> Qr <1B> <09> Rs <1B> <09> St <1B> <09> Tu <1B> <09> Uv <1B> <09> Vw <1B> <09> Wx <1B> <09> Xy <1B> <09> Yz
<1D> <09> <09>{ <1B> <09> [| <1B> <09> \}
<1B> <09> ]~ <1B> <09> ^ <1B> <09> _<02> <1B> <09> `<02> <1B> <09> a<02> <1D> <09> C<02> <1D> <09> Z<02> <1B> <09> b<02> <1B> <09> c<02> <1B> <09> d<02> <1B> <09> e<02> <1B> <09> f<02> <1B> <09> g<02> <1B> <09> h<02> <1B> <09> i<02> <1B> <09> j<02> <1B> <09> k<02> <1B> <09> l<02> <1B> <09> m<02> <1B> <09> n<02> <09><1B> <09> o<02> <09><1B> <09> p<1B> <09> q<02> "<1B> <09> r<02> <09><1B> <09> s<02> <09><1B> <09> t<02> #<1B> <09> u<02> $<1D> <09> v<02> %<1D> <09> w<02> &<1D> <09> x<02> '<1D> <09> y<02> (<1D> <09> z<02> )<1D> <09> {<02> *<1D> <09> |<02> +<1B> <09> <02> ,<1B> <09> <09><02> -<1B> <09> <09><02> .<1B> <09> <09><02> /<1B> <09> <09><02> 0<1B> <09> <09><02> 1 <09> <09><02> 2 <09> <09><02> 3 <09> <09><02> <09>
<09><02> <09>
 <09><02> 4
 <09><02> 5
 <09><02> 6
 <09><02> 7
 <09><02> 8
 <09><02> 98
 <09><02> :#
 <09><02> ;?
<09><02> <@
<09><02> =y
<09><02> >K
<09><02> ?P
<09><02> @Q
 <09><02> AT
 <09><02> BY
 <09><02> <09>Z
 <09><02> D]
 <09><02> Eb
 <09><02> Fc
 <09><02> Gk
 <09><02> Hl
 <09><02> I<1C>
 <09><02> Jj
 <09><02> Kk
 <09><02> Lp
 <09><02> Mq
 <09><02> N}
 <09><02> O~
 <09><02> P
 <09><02> Q<1D>
<09><02> R<1D>
! <09><02> S<1D>
" <09><02> T<08> <08><08><08> abstraction<08><08>data<08><08><02>object<1D><08>  Von Neumann<08> 
(object:identity;object:type;object:value<08> <02>object:address in memory<08> <02>object:mutable <08> dobject:immutable<08> garbage collection <08> ireference:counting k<08> <02>&circular references;reference:circular <09><08> pobject:unreachable r<08> <02> debugging<6E> t<08>
<02>try<72><08> v%object:reference to external resource(<1D><08> )close{ *<08>
|finally<6C><08> <02>object:container;container /<08> <02>0type;type:data;type:hierarchy;module:extension;C<08> <02>Eattribute;attribute:special;attribute:generic;__methods__;__members__<5F> 9<08> <02>number <09><08> ?numeric<08> 
=integer<65><08> 
<EFBFBD>
plain integer@Q<08> 
A long integer<08>  <0B>None<08> ]representation:integer <09><08> kC<> H<08> <02>double precision<08> Kfloating point <09><08> qcomplex number O<08> 
<EFBFBD>sequence<08> <02>sequence:immutable;immutable<08> ASCIIab<08> 
ostring<08> byte<08> * tchr<68><08> "o/len;index operation;item:selection;subscription;<08> #lslicing<08> $ ttracback object:tb_next<08> % tEllipsis<08> & dorde<08> 'barray of bytesag<08> ( ctracback object:tb_frame<08> ) gtracback object:tb_linenorce<08> !
etuplecar<08> +
tuple:singletona<08> -
r tuple:emptyu<08> , t__or__tr<08> . __radd__<08> / n__neg__e<08> 0 u__pos__<5F><08> 1 l__abs__<5F><08> 2 i
__invert__<02><08> 4 t__cmp__r<08> 5 r
__coerce__ty<08> 6 :__int__:<08> 7 ;__long__<08> 8 __float__tib<08> 9 r__oct__c<08> : b__rsub__<08> ; d__rmul__<08> < 9__rdiv__<08> = <0B>__rmod__<08> > __rdivmod__e<08> ? __rpow__<08> @ @ __rlshift__ <08> A g __rrshift__<08> B __rand__<08> C n__rxor__<08> D k__ror__<5F><08> Eobitwise operationsK<08> F i__sub__<08> G q__mul__ <08> H O__div__<08> I __mod__<08> J i
__divmod__ab<08> K __pow__I<08> L 
__lshift__<08> M
__rshift__ t<08> N __and__/<08> O __xor__;<08> P c__hex__c<08> Q
sequence:mutable<08> Rt subscription<08> Sxslicing<08> Usdel<65><08> Vrstatement:assignment;assignment<6E><08> 3 r __delslice__<08> ]
list<08> ^
amapping:<08> _ rlen<65><08> `u subscription<08> a
dictionary -<08> bumutableu<08> ct3call:function invocation;argument:function;callable<6C><08> f_function:user-defined;function i<08> kemethod:user-definedm<08> l5object closurety<08> m: user-defined<08> n _function object:func_doc<08> o 9__doc__c p :__name__  q ;function object:func_name_iv  r =function object:func_defaultsvd_  s ?function object:func_code_sh  t function object:func_globals  udname space:globalr  vkmethod:user-defined:creation  wsmethod:unboundb_  x Gmethod object:im_selfO__ y method object:im_funcJ i
z mmethod object:im_class { __doc__t | Mmethod object:__name__
} _method object:im_func.__doc__c__  ~ method:bound   bim_self  <09>r optimization  <09>ntransformation  <09>rCtem  <09>
ifunction:built-in;built-in__  <09>
emethod:built-int  <09> a__self__  <09>
rclass;class instance;instance a  <09>icall:class objectumu  <09> __init__  <09> t__call__  <09>mimporton  <09>
lmodule_  <09> i__dict__  <09> c__name__  <09> e__doc__-  <09> __file__ <09>oname space:modules-d ! <09> function object:func_globals " <09>
oclass;class instance # <09>
e
dictionaryfu $ <09>oattribute search % <09>=attribute:class: & <09> uim_class ' <09>u containercfu ( <09>_assignment:attribute:classfu ) <09>acall:class objectsce * <09> r__dict__ + <09> d __bases__ecr , <09> __name__ - <09> b__doc__ . <09>
eclass;instance;instance:classme / <09>j<attribute:class instance;assignment:attribute:class instance 0 <09> __getattr__h 1 <09> : __setattr__
2 <09> e __delattr__m 3 <09> o)32560: 1Heading: 3.3 Special method namesmel 4 <09>
<EFBFBD>numbermi 5 <09>
6 <09>
rsequence 7 <09>
<EFBFBD>mapping 8 <09> i__dict__ 9 <09> ; __class___ <09> : <09> eopen ; <09> popena__ < <09> fdopencl = <09> smakefile > <09> stdin;sys.stdinl ? <09> jstdout;sys.stdout_it @ <09> <0B>stderr;sys.stderr<72>m A <09>
tfile B <09> o__str__ C <09> _str_ D <09>c
internal type<70> e E <09>
_ code object F <09> byte-compile G <09>dbytecode H <09>ufunction objectc I <09> frame object:f_localsnan J <09> <0B>code object:co_argcount K <09> bcode object:co_nlocalsib L <09> scode object:co_varnames' M <09> ocode object:co_code N <09> tcode object:co_consts<74>a O <09> ccode object:co_names P <09> tcode object:co_filename Q <09> code object:co_flags R <09> code object:co_constsens S <09> l getlineno<6E>j T <09>
bframesin U <09> aframe object:f_backl V <09> nframe object:f_codet W <09> <0B>frame object:f_globals e X <09> aframe object:f_builtins1 Y <09> 3frame object:f_restrictedl <09> Z <09>uprinti <09> [ <09> frame object:f_lineno<6E>
<EFBFBD> \ <09> nframe object:f_lasti ] <09> ;frame object:f_trace ^ <09>debugger _ <09>_ stack framep ` <09> <0B>2sys:last_traceback;traceback object:last_tracebackst a <09> s0sys:exc_traceback;traceback object:exc_traceback b <09>handler:exception <09> c <09>ttrace:stack;stack:execution d <09> _tracback object:tb_lasti e <09>itryG f <09>y
Slice objectsufu g <09>oextended slice syntax je h <09>cellipsis i <09> o __getitem__a j <09> __init__ k <09> c__del__a l <09><0E>del m <09>cconstructor:class<73> o n <09>o__del__:exception in o <09> osys.exc_tracebacka <09> p <09> osys.last_traceback <09> q <09>oreference:countn r <09> <0B>__repr__ s <09> orepr t <09>*quotes:reverse;quotes:backward;back-quoteso<> u <09><02>conversion:string<6E> a v <09> __repr__ w <09> <0B>__hash__ x <09>
f
dictionary <0B> y <09> hash z <09>
s+14279 a { <09> __nonzero__t | <09> <0B>__len__m  <09>fattribute access <09> <09> r __getattr__ <09> <09> __setattr__n <09> <09> <0B>__dict__ <09> <09> f __delattr__ <09> <09> __call__ <09> <09><02>
instance:call <09> <09> <09> t __getitem__` <09> <09> y __setitem__a <09>
a __delitem__t <09>
 k__len__ <09>
 x __nonzero__r <09>
 b __getslice__ <09>
 <0B> __setslice__ <09>
slice<63>t <09>
:extended slice notationd <09>
 r__add__j <09>
sbinary arithmetic operations <09>
ecoercion rulesex <09>
snumeric arithmetic:mixed modes <09>
o+25380m_ <09>
<EFBFBD>-25380it <09>

<EFBFBD>=25380l_ <09>

<EFBFBD>+17599 <09>

c-17599to <09>

<EFBFBD>=17599o <09>

_+39782n <09>

<EFBFBD>-39782ex <09>

b=39782 <09> <09>

y-14279ce <09>

<EFBFBD>=14279re <09>
:
OverflowError<EFBFBD>__ <09>
AttributeError <09> <09>
 u%19057: Chapter: Chapter 3: Data modelso<> <09>
 <09>022319: 1Heading: 3.2 The standard type hierarchy <09>
 hx18920: HangIndentLev2: Slice objects Slice objects are used to represent slices when extended slice syntax is used (this <09>
 eo27144: HangIndentLev2: Traceback objects Traceback objects represent a stack trace of an exception. A traceback_ <09>
 <0C>idan <09>
 is <09> <09>
 _type <09>
<02>type <09>
!_object:identitye <09>
" object:value a q b a <09><05>onzo_ d <09><05> b__ e <09><05>_<03><03><03>__4<5F>0j<><03> <09><05><03>*27031: 2Heading: 5.2.5 Dictionary displays
4<><34><EFBFBD> a<><03> <09><05><03>)27502: 1Heading: 7.5 Function definitionsci4<69>0k<><03> <09><05><03>s41934: 2Heading: 5.3.4 Calls4<><34><EFBFBD>D<><03> <09><05><03>_017806: 1Heading: 6.10 The import statementimport4<><34><EFBFBD> b<><03> <09><05><03>9&23237: 1Heading: 7.6 Class definitions
4<><34><EFBFBD><01><><03> <09><05>)32560: 1Heading: 3.3 Special method names794<39><34><EFBFBD> d,<03> <09><05><03>l&13811: 1Heading: 7.4 The try statement<05><05><05>7:<05><$lastpagenum><05><$monthname> <$daynum>, <$year>3 T<05>"<$monthnum>/<$daynum>/<$shortyear><05>;<$monthname> <$daynum>, <$year> <$hour>:<$minute00> <$ampm>sce<05>"<$monthnum>/<$daynum>/<$shortyear><05><$monthname> <$daynum>, <$year>a o<05>"<$monthnum>/<$daynum>/<$shortyear><05> <$fullfilename> ac<05>
<$filename>dan<05> <$paratext[Title]><05> <$paratext[Chapter]>ob<05>
<$curpagenum><05>
<$paratext[2Heading]><3E><05>
<$marker2><05> (Continued)<03><05>+ (Sheet <$tblsheetnum> of <$tblsheetcount>)Dti<05>Heading & Page <20><$paratext><3E> on page<$pagenum><05>Pagepage<$pagenum>n<05>See Heading & Page%See <20><$paratext><3E> on page<$pagenum>.<2E>D<><05> Table All07Table<$paranumonly>, <20><$paratext>,<2C> on page<$pagenum> <05>Table Number & Pagee'Table<$paranumonly> on page<$pagenum><3E><03><03><03><03> <c>ref5.docng:<03> <c>ref7.docod <03> <c>ref6.doc <07><07><07>
<03><07><03><03><07><03><03><07><03><03>Aohn<07><03><03>A"<07><03><03>PHIDDEN<07> ,Ae> <07>77<07>99<07>;;A>$d<07>==m<08><07><00><14>mW$ea nOOfi<14>oLc pPd <14>qXele.rRte0sP>ctT<14>uLa[2 vM Chapter 3:>"wNo3.1:xO heDyL$etEzLiHeF{LearG|LppaH}LI~Ln@Ne3.2SeV<07>Ox pg<07>TTuD<><1A><07>R Ta<07>Pu, d<07>>pah<07>Rmj<07>Sbagn<07>T$mor<07>Teenv<07>S<06><03><07>Ro<1A><07>So<07>o<07><00><07><07>R<07>T<00><07>S<00><07>TAo<00><07>U <07>R"<1A><07>R<03><00><07>SIB<07>P <00><07>Pe<00><07><00><07>R<00><07>S?<07>;<00><07>P>I<07><1B><07>SS<1C><14>d<07>S <07>S<14><1D><07>SR<07>R<14>d<07>R.<07>R0*<07>Rc0<07>P<14>2<07> <<07>te<04><07>"o<07>P:!<07>LPD{<07>E|<07>F<04><07>Gd<07>PHh<07>Ip<07>@v<07>2<01><07>PO<11><07>PT<04><07>RR<11><07>SP<01><07>RC<07>VVR3.3.3S<01><07>RgT6<07>LVoT<01><07>Nn3.3b<07>LRc<07>LLS<13><07>P<01><07>P<01><07>R<03><07>T<01><07>PS<1D><07>PT<1D><07>PU9<07>PRH<07>LR<07>VS3.3.2P7<07>P P$<07>P(<07>R,<07>PS0<07>R<07>P ;P6<07>V3.3.4:<07>P<04><14>><07>P B<07>P<14>F<07>PH<07>K3.3.4.1L<07>PRP<07>PR[<07>R V<07>V3.3.5q<07>[eZ<07>[oP\<07>[:L^<07>[D`<07>[Eb<07>[Fd<07>[GPf<07>[Hh<07>[Ij<07>[@l<07>[PZ<07>[P[<07>PR<02><07>[S<02><07>[R<02><07>[V<1D><07>P3<02><07>PRm<07>PL<13><07>TQN<14><07>PL<14><07>[L<14><07>[Pz<07>[P><07>SRJ<07>SSa<07>SSPo<07>RRP(<07>LPP<07>PP<1D><07>PPL <07>SRV<07>[2<07>[P<07>[P<07>[<07>[P <07>[!<07>[P"<07>[V#[$[>sPB<14>PF<13>RQH<13>TT<14>[P<13>RTP<13>TQR<13> TTV<13>
RT5<13> TT[<13> TT[<14>
R[<13>RQ[<13>V[3.3.1[ELV[GLKP<14>TR[<14>TT[<14>TT[<14>W[<14>XP<14>L[<14>Y[<02>VYS[<19>\PP<03>I<03>G<02>d<14><03>MTN<03>=<03>L<14>d<14><03>M[<03><03><03>Jc$<01> <14><03>N<03><03>Rc$<01> l <0E><><03><03><07>c$<01> <14><03>N<03> c$<01>  [<03>`m<05>! Pc<02><01> <14><03>N<03><03><03>c<02><01> l <0E><><03><03><07><13>c<02><01> <14><03>N<03> [c<02><01>  <09><> <03><06><><06><>UUnq<05>[  Y# Z TcH<01><02><14><03>O<03>=<03>[cH<01><02>l <0E><><03><03><07>LcH<01><02><14><03>N<03> <0C>TcH<01><02>
<EFBFBD><EFBFBD>[<14><03>UTUT<03><>euY [cH<01><02><14><03>O<03><03>cH<01><02>l <0E><><03><03><07>cH<01><02><14><03>N<03> <14>cH<01><02>
<EFBFBD><EFBFBD>J<03>UTUT<03><>eoR d<14><03>M<00><><03>B<03>H<17>m3R<33> <19><14><03>O<03><03> H<17>m3R<33> <19>H RH R<05>FootnoteHr<19>@ <19><14><03>O<03><03><03> PHr<19>@ <19>Hz<><7A>Hz<><7A><05> Single Line<6E>H'<00><0E><><14><03>N<03><03><03><03><03><03>Footnote 
<00><14><03>P<03> 
<00>  
<00>
H<00><19>D<> <19><14><03>Q<03><03><03> TH<00><19>D<> <19>H<00><><EFBFBD>H<00><><EFBFBD><05> Double LineHH<00><><EFBFBD><01> <14><03>N<03>?<03><03><03><03> Double Line<6E><01><14><03>R<03><03><01><14><01><01><14><03>R<03><03><01><01>dF<03>M<0E><03><03><03><14>NHH<01><02>G<03>N<03> HH<01><02>Z<><5A>UT<03>RUT<03><>m<07>z<14>

z

UT<03><>m<07>zB

z

UT<03><>m<07>z<19>

 

UT<03><>m<07>z

 

UT<03><>e<07>R HH<01><02>I<03>N<03><13>HH<01><02>l<0E><><03><03><07><00>d M<03>  <03>FocH<01><02>/
N cH<01><02><02><><EFBFBD>**H<00><19> <14>*
<EFBFBD><EFBFBD>
<EFBFBD><EFBFBD>UUhv<05>
Data model
<EFBFBD><EFBFBD><EFBFBD>1US UT<04><>`w}leObjects, values and types
JUQUT<03><>(x<05>}<08>Objects are Python<6F>s <08>abstraction for <08>data. All data in a Python program is represented by objects or WUOUT<03><>xbby relations between objects. (In conformance to  Von Neumann<6E>s model of a <20>stored program comdUMUT<03><>@x.puter<65>, code is also represented by objects.)
}UKUT<03><>(yNzEvery  object has an identity, a type and a value. An object<63>s <05>
!identity never changes once it has been <00>UIUT<03><>yUTxcreated; you may think of it as the  object<63>s address in memory. The <20><05>
is<1B> operator compares the iden<00>UGUT<03><>yNstity of two objects; the <20><05>
id()<1B> function returns an integer representing its identity (currently imple<00>UEUT<03><>ypmented as its address). An object<63>s <05>
type is also unchangeable. It determines the operations that an <00>UCUT<03><>yiobject supports (e.g. <20>does it have a length?<3F>) and also defines the possible values for objects of that Q<00>UAUT<03><>y|type. The <20><05>
type()<1B> function returns an object<63>s type (which is an object itself). The <05>
"value of some UO<00>U?UT<03><>ybyiobjects can change. The <20><05>==<1B> operator compares the value of two objects. Objects whose value can <20><00>U=UT<03><>ycopchange are said to be <05> mutable; objects whose value is unchangeable once they are created are called . <00>U;UT<03><>y<05>!l immutable. An object<63>s (im)mutability is determined by its type; for instance, numbers, strings and ob<00>U9UT<03><>@yme@tuples are immutable, while dictionaries and lists are mutable.
<EFBFBD><EFBFBD> U7UT<03><> ztw^Objects are never explicitly destroyed; however, when they become unreachable they may be garU5UT<03><>zUTlbage-collected. An implementation is allowed to postpone  garbage collection or omit it altogether <20> ra%U3UT<03><>zUCfit is a matter of implementation quality how garbage collection is implemented, as long as no objects 2U1UT<03><>z Qnare collected that are still reachable. (Implementation note: the current implementation uses a  refer?U/UT<03><>zlugence-counting scheme which collects most objects as soon as they become  unreachable, but never twLU-UT<03><>Hz w6collects garbage containing  circular references.)
eU+UT<03><>({enNote that the use of the implementation<6F>s tracing or  debugging facilities may keep objects alive that rU)UT<03><>{imlwould normally be collectable. Also note that catching an exception with a <20><05>
try...except<1B> statemmU'UT<03><>@{ioment may keep objects alive.
<EFBFBD><01>U%UT<03><>(|twkSome objects contain  references to <20>external<61> resources such as open files or windows. It is underz<01>U#UT<03><>|edhstood that these resources are freed when the object is garbage-collected, but since garbage collection <20><><01>U!UT<03><>|maiis not guaranteed to happen, such objects also provide an explicit way to release the external resource, z<01>UUT<03><>|d ousually a <05>close() method. Programs are strongly recommended to always explicitly  close such oblu<01>UUT<03><>H|he[jects. The <20><05>try...<05>
finally<1B> statement provides a convenient way to do this.
UT<01>UUT<03><>(}ecrSome objects contain references to other objects; these are called <05> containers. Examples of containers <01>UUT<03><>}ughare tuples, lists and dictionaries. The references are part of a container<65>s value. In most cases, when t<01>UUT<03><>}cejwe talk about the value of a container, we imply the values, not the identities of the contained objects;  UUT<03><>} ofhowever, when we talk about the (im)mutability of a container, only the identities of the immediately UUT<03><>}edfcontained objects are implied. So, if an immutable container (like a tuple) contains a reference to a &UUT<03><>@}|Emutable object, its value changes if that mutable object is changed.
t?UUT<03><> ~e gTypes affect almost all aspects of object behavior. Even the importance of object identity is affected ndeLU
UT<03><>~itcin some sense: for immutable types, operations that compute new values may actually return a refert pYU UT<03><>~ntcence to any existing object with the same type and value, while for mutable objects this is not al cafU UT<03><>~in{lowed. E.g. after <20><><05>a = 1; b = 1<><31>, <05>a and <05>b may or may not refer to the same object with the value nersUUT<03><>~cavone, depending on the implementation, but after <20><><05>c = []; d = []<1B><>, <05>c and <05>d are guaranteed to <02>UUT<03><>~; irefer to two different, unique, newly created empty lists. (Note that <20><><05>c = d = []<1B><> assigns the <02>UUT<03><>@~U.same object to both <05>c and <05>d.)
cH<01><02> O ecocH<01><02>l <0E><>

<07>d<02> Mhge<03>Tys L<>H<01><02>3
N rEvL<>H<01><02><02><><EFBFBD>bj-- ndeLU
it- UT UT<04><>h}ab 
The standard type hierarchy
ne"URUT<03><> <07>llfBelow is a list of the types that are built into Python. Extension modules written in C can define ad/UPUT<03><><07>ctfditional types. Future versions of Python may add types to the type hierarchy (e.g. rational numbers, <UNUT<03><>H<07>ot2efficiently stored arrays of integers, etc.). 
OULUT<03><> n dcSome of the type descriptions below contain a paragraph listing <20>special attributes<65>. These are atran\UJUT<03><>n<><7F>ftributes that provide access to the implementation and are not intended for general use. Their definiiUHUT<03><>nUTetion may change in the future. There are also some <20>generic<69> special attributes, not listed with the evUFUT<03><>nkindividual objects: <05>__methods__ is a list of the method names of a built-in object, if it has any; <20><00>UDUT<03><>Hn<05><>___members__ is a list of the data attribute names of a built-in object, if it has any. 
LU
<00>UBUT<03><>(p<05>m NoneThis type has a single value. There is a single object with this value. This object is accessed t<00>U@UT<03><>p Pcthrough the built-in name <05>None. It is used to signify the absence of a value in many situaion<00>U>UT<03><>pd dtions, e.g. it is returned from functions that don<6F>t explicitly return anything. Its truth value is i<00>U<UT<03><>@p
false.
<03><><00>U:UT<03><>(<07><05>thr %Ellipsis This type has a single value. There is a single object with this value. This object is accessed <00>U8UT<03><><07>e fthrough the built-in name <05>Ellipsis. It is used to indicate the presence of the <20><>...<2E><> syntax <00>U6UT<03><>H<07>he)in a slice. Its truth value is true.

i<00>U4UT<03><>(<07><05> loNumbers These are created by  numeric literals and returned as results by arithmetic operators and bui
U2UT<03><><07>t ]arithmetic built-in functions. Numeric objects are immutable; once created their value never iU0UT<03><><07>t dchanges. Python  numbers are of course strongly related to mathematical numbers, but subject ec$U.UT<03><>@<07> T=to the limitations of numerical representation in computers.
-5U,UT<03><>`<07>BPython distinguishes between integers and floating point numbers:
HU*UT<03><>h<07><05>tiV Integers These represent elements from the mathematical set of whole numbers
YU(UT<03><>`<07>UT!There are two types of integers:
<EFBFBD>lU&UT<03><>(<07><05>ps] Plain integers These represent numbers in the range -2147483648 through 2147483647. ayU$UT<03><><07><><7F>N(The range may be larger on machines with a larger natural word size, but not <01>U"UT<03><><07><>.Rsmaller.) When the result of an operation falls outside this range, the exception <01>U UT<03><><07><05>erT
OverflowError is raised. For the purpose of shift and mask operations, inteet<01>UUT<03><><07>uiLgers are assumed to have a binary, 2<>s complement notation using 32 or more ab<01>UUT<03><><07>heTbits, and hiding no bits from the user (i.e., all 4294967296 different bit patterns ro<01>UUT<03><>@<07>th!correspond to different values).
.<01>UUT<03><>(<07><05>to` Long integers These represent numbers in an unlimited range, subject to available (virsh<01>UUT<03><><07>s Ptual) memory only. For the purpose of shift and mask operations, a binary repret <01>UUT<03><><07>maOsentation is assumed, and negative numbers are represented in a variant of 2<>s ger<01>UUT<03><><07><07>Qcomplement which gives the illusion of an infinite string of sign bits extending uUUT<03><>@<07>U$
to the left.
<EFBFBD>UUT<03><>(<07>e aThe rules for integer  representation are intended to give the most meaningful interpretaeU UT<03><><07>at[tion of shift and mask operations involving negative integers and the least surprises when ise,U
UT<03><><07> o[switching between the plain and long integer domains. For any operation except left shift, 2<>s9UUT<03><><07>on^if it yields a result in the plain integer domain without causing overflow, it will yield the FUUT<03><>@<07>itEsame result in the long integer domain or when using mixed operands.
YUUT<03><>(<07><05> nFloating point numbers These represent machine-level  double precision  floating point numfUUT<03><><07> o_bers. You are at the mercy of the underlying machine architecture and  C implementation on sUUT<03><><07>gaVfor the accepted range and handling of overflow. Python does not support single-preci<02>T<EFBFBD>UT<03><><07>ioVsion floating point numbers; the savings in CPU and memory usage that are usually the <02>T<EFBFBD>UT<03><><07>ThZreason for using these is dwarfed by the overhead of using objects in Python, so there is L<>H<01><02><02>O  skL<>H<01><02>l<0E><> 

<07>nd<02>Mwn <03> daicH<01><02>7N sUcH<01><02>v<><76>t ++lain intth+UTUT<03><>H<07>ilSno reason to complicate the language with two kinds of floating point numbers.

1997-05-08 23:39:55 +00:00
g mURUT<03><>(r<05>UcComplex numbers These represent  complex numbers as a pair of machine-level double pre'UPUT<03><>rt Ycision floating point numbers. The same caveats apply as for floating point numbers. The 4UNUT<03><>rem_real and imaginary value of a complex number <05>z can be retrieved through the attributes t sAULUT<03><>@r<05>iz.real and <05>z.imag.
ng TUJUT<03><>(s<05> si Sequences These represent finite ordered sets indexed by natural numbers. The built-in function aUHUT<03><>s<05> uelen() returns the number of items of a sequence. When the length of a sequence is <05>n, the nUFUT<03><>Hs{index set contains the numbers 0, 1, ..., <05>n. Item <05>i of sequence <05>a is selected by <05>a[i]. "
7UDUT<03><>(<07> sdSequences also support  #slicing: <05>a[i:j] selects all items with index <05>k such that il<00>UBUT<03><><07><05>plZi<=k<j. When used as an expression, a slice is a sequence of the same type <20> this <00>U@UT<03><>@<07>TGimplies that the index set is renumbered so that it starts at 0 again.
pre<00>U>UT<03><>`<07>r;Sequences are distinguished according to their mutability:
s f<00>U<UT<03><>(<07><05>nufImmutable sequences An object of an  immutable sequence type cannot change once it is cre<00>U:UT<03><><07>ib[ated. (If the object contains references to other objects, these other objects may be mutauen<00>U8UT<03><><07>reOble and may be changed; however the array of objects directly referenced by an UT<00>U6UT<03><>@<07>)!immutable object cannot change.)
1997-05-08 23:39:55 +00:00
a<00>U4UT<03><>`<07>e -The following types are immutable sequences:
TU2UT<03><>(<07><05>x fStringsThe items of a  string are characters. There is no separate character type; a charU0UT<03><><07>UDTacter is represented by a string of one item. Characters represent (at least) 8-bit w"U.UT<03><><07> i bytes. The built-in functions  *<05>chr() and  &<05>ord() convert between characters and s/U,UT<03><><07>U@Ononnegative integers representing the byte values. Bytes with the values 0-127 ag<U*UT<03><><07><><7F>Xusually represent the corresponding  ASCII values, but the interpretation of valnuIU(UT<03><><07>ce[ues is up to the program. The string data type is also used to represent  'arrays of <03><>VU&UT<03><>@<07>f +bytes, e.g. to hold data read from a file.
ts,gU$UT<03><>`<07>tsL(What should be done on systems whose native character set is not ASCII???)
y zU"UT<03><>(<07><05>y bTuplesThe items of a  !tuple are arbitrary Python objects. Tuples of two or more items <01>U UT<03><><07>arXare formed by comma-separated lists of expressions. A  +tuple of one item (a <20>sine <01>UUT<03><><07>isNgleton<6F>) can be formed by affixing a comma to an expression (an expression by <01>UUT<03><><07>itQitself does not create a tuple, since parentheses must be usable for grouping of i<01>UUT<03><><07>*Vexpressions). An  -empty tuple can be formed by enclosing <20>nothing<6E> in parenthe<01>UUT<03><>@<07>geses: <20><><05>()<1B><>.
<01>UUT<03><>(<07><05>h mMutable sequences  QMutable sequences can be changed after they are created. The  Rsubscripe<01>UUT<03><><07>nuztion and  Sslicing notations can be used as the target of V assignment and U <05>del (delete) state<01>UUT<03><>@<07>s,ments.
ol<01>UUT<03><>`<07> f3There is currently a single mutable sequence type:
sy UUT<03><>(t<05> c^ ]ListsThe items of a list are arbitrary Python objects. Lists are formed by placing a U UT<03><>t oPcomma-separated list of expressions in square brackets. (Note that there are no ra&U
UT<03><>@tss6special cases needed to form lists of length 0 or 1.)
9UUT<03><>`<07> c]The optional module <05>array provides an additional example of a mutable sequence type.
fLUUT<03><>(<07><05> ty ^Mappings These represent finite sets of objects indexed by arbitrary index sets. The ` subscript notation oYUUT<03><><07><05><>noa[k] selects the item indexed by <05>k from the mapping <05>a; this can be used in expressions and  QfUUT<03><><07> cpas the target of assignments or <05>del statements. The built-in function <05> _len() returns the numnssUUT<03><>@<07>e ber of items in a mapping.
andcH<01><02><02>OT<00><>cH<01><02>l <0E><><07>a sd<02>M<0E>t<03>emofL<>H<01><02>;N e L<>H<01><02>r<><72>U --separatees-UTUT<03><>`<07>(N4There is currently a single intrinsic mapping type:
caURUT<03><>(<07><05> le aDictionaries These represent finite sets of objects indexed by nearly arbitrary values. The e'UPUT<03><><07>e [only types of values not acceptable as keys are values containing lists or dictionaries or s i4UNUT<03><><07>y Xother mutable types that are compared by value rather than by object identity <20> the ream AULUT<03><><07>Yson being that the efficient implementation of dictionaries requires a key<65>s value to resNUJUT<03><><07>igMmain constant. Numeric types used for keys obey the normal rules for numeric n[UHUT<03><><07>UTVcomparison: if two numbers compare equal (e.g. 1 and 1.0) then they can be used interhUFUT<03><>@<07>/changeably to index the same dictionary entry.
yUDUT<03><>(<07><02>gDictionaries are  bmutable; they are created by the <05>{...} notation. ( eSee <20>Dictionary disL<><00>UBUT<03><>H<07>U plays<79> on page28. d)
pa<00>U@UT<03><> <07>eslThe optional library modules <05>dbm, <05>gdbm and <05>bsddb provide additional examples of mapDi<00>U>UT<03><>@<07>es ping types.
ni<00>U<UT<03><>(<07><05> inCallable types These are the types to which the function call operation (for invocation,  iSee <20>Calls<6C> <00>U:UT<03><>H<07>st!on page31. j) is applied c:
<EFBFBD><00>U8UT<03><>*<07><05>tahUser-defined functions A  fuser-defined function object is created by a function definition. be<00>U6UT<03><>J<07>ie1( gSee <20>Function definitions<6E> on page50. h)
v<00>U4UT<03><>(<07>UTjSpecial read-only attributes: <05> nfunc_doc or <05> o__doc__ is the function<6F>s documentation U2UT<03><><07>ifnstring, or <05>None if unavailable; <05> qfunc_name or <05> p__name__ is the function<6F>s name; U0UT<03><><07><05>arX rfunc_defaults is a tuple containing default argument values for those arguments <20>U.UT<03><><07>. gthat have defaults, or <05>None if no arguments have a default value; <05> sfunc_code is the ion)U,UT<03><><07> ^code object representing the compiled function body; <05> tfunc_globals is (a reference 6U*UT<03><><07>nicto) the dictionary that holds the function<6F>s global variables <20> it defines the  uglobal name or CU(UT<03><><07>e Vspace of the module in which the function was defined. Additional information about a PU&UT<03><><07>ns]function<6F>s definition can be retrieved from its code object; see the description of internal <20>]U$UT<03><>@<07> <20>
types below.
tpU"UT<03><>(<07><05> hj kUser-defined methods A user-defined method object (a.k.a. <05> lobject closure) combines a }U UT<03><><07>atLclass, a class instance (or <05>None) and a  muser-defined function. _n<01>UUT<03><><07>_nSpecial read-only attributes: <05> xim_self is the instance object; <05> yim_func is the function <01>UUT<03><><07>thdobject; <05> zim_class is the class that defined the method (which may be a base class of the lt<01>UUT<03><><07>ncbclass of which <05>im_self is an instance); <05> {__doc__ is the method<6F>s documentation <01>UUT<03><><07> X(same as <05> }im_func.__doc__); <05> |__name__ is the method name (same as va<01>UUT<03><>@<07><05>esim_func.__name__).
r <01>UUT<03><>(<07>e bUser-defined  vmethod objects are created in two ways: when getting an attribute of a class <01>UUT<03><><07><>s_that is a user-defined function object, or when getting an attributes of a class instance that @<07><01>UUT<03><><07>
t`is a user-defined function object. In the former case (class attribute), the <05>im_self atbj<01>UUT<03><><07>omotribute is <05>None, and the method object is said to be <05> wunbound; in the latter case (instance UTU UT<03><><07>iakattribute), <05>im_self is the instance, and the method object is said to be <05> ~bound. For inUTU
1997-05-08 23:39:55 +00:00
UT<03><><07>ctsstance, when <05>C is a class which contains a definition for a function <05>f, <05>C.f does not yield bclUUT<03><><07>m_ethe function object <05>f; rather, it yields an unbound method object m where <05>m.im_class *UUT<03><><07>._<00>is <05>C, <05>m.im_function is <05>f, and m<05>.im_self is <05>None. When <05>x is a <05>C instance, <05>x.f n7UUT<03><><07>obvyields a bound method object <05>m where <05>m.im_class is <05>C, <05>m.im_function is <05>f, and DUUT<03><>@<07><05>gem.im_self is <05>x.
iUUUT<03><> <07>UNWhen an unbound user-defined method object is called, the underlying function bT<62>UT<03><><07>ia(<05>im_func) is called, with the restriction that the first argument must be an instance of oT<6F>UT<03><>@<07>; Cthe proper class (<05>im_class) or of a derived class thereof.
imL<>H<01><02><02>ObctL<>H<01><02>l<0E><><07>ctd<02>Moai<03>ti cH<01><02>?N UTcH<01><02><02><><EFBFBD>ti..her, it un.UTUT<03><> <07><>]When a bound user-defined method object is called, the underlying function (<05>im_func) <20>URUT<03><><07><05>dis called, inserting the class instance (<05> im_self) in front of the argument list. For inet!UPUT<03><><07>ustance, when <05>C is a class which contains a definition for a function <05>f, and <05>x is an instance .UNUT<03><>@<07>UTQof <05>C, calling <05>x.f(1) is equivalent to calling <05>C.f(x, 1).
1997-05-08 23:39:55 +00:00
f?ULUT<03><>(<07><><7F>^Note that the  <09>transformation from function object to (unbound or bound) method object LUJUT<03><><07>UTZhappens each time the attribute is retrieved from the class or instance. In some cases, a YUHUT<03><><07>Offruitful  <09>optimization is to assign the attribute to a local variable and call that local varifUFUT<03><><07>Zable. Also notice that this transformation only happens for user-defined functions; other sUDUT<03><>@<07>tiVcallable objects (and all non-callable objects) are retrieved without transformation.
<00>UBUT<03><>(<07><05>thm <09>Built-in functions A built-in function object is a wrapper around a  <09>C function. Examples of c<00>U@UT<03><><07>jbuilt-in functions are <05>len and <05>math.sin (<05>math is a standard built-in module). The <00>U>UT<03><><07> aUnumber and type of the arguments are determined by the C function. Special read-only T<00>U<UT<03><><07>lldattributes: <05>__doc__ is the function<6F>s documentation string, or <05>None if unavailable; <00>U:UT<03><><07><05> fh__name__ is the function<6F>s name; <05> <09>__self__ is set to <05>None (but see the next paraut<00>U8UT<03><>@<07>m graph).
r<00>U6UT<03><>(<07><05> ck <09>Built-in methods This is really a different disguise of a built-in function, this time containing d c<00>U4UT<03><><07>iXan object passed to the C function as an implicit extra argument. An example of a built-in<00>U2UT<03><><07>r din method is <05>list.append, assuming <05>list is a list object. In this case, the special tiU0UT<03><>@<07><07>Tread-only attribute <05>__self__ is set to the object denoted by <05>list.
U.UT<03><>(<07><05>mpp <09>Classes Class objects are described below. When a class object is calle <09>d, a new class instance bu!U,UT<03><><07>e S(also described below) is created and returned. This implies a call to the class<73>s on..U*UT<03><><07><05> T` <09>__init__ method if it has one. Any arguments are passed on to the <05>__init__ methon;U(UT<03><>@<07>leYod <20> if there is no <05>__init__ method, the class must be called without arguments.
tNU&UT<03><> <07><05>t bClass instances Class instances are described below. Class instances can be called as a func[U$UT<03><><07>ifdtion only when the class has a <05> <09>__call__ method; in this case, <05>x(arguments) is a thU"UT<03><>@<07>s -shorthand for <05>x.__call__(arguments).
l{U UT<03><>*<07><05><07>xModules Modules are imported by the <05> <09>import statement. ( <09>See <20>The import statement<6E> on page43. <09>) <07><01>UUT<03><><07>tr`A  <09>module object has a name space implemented by a dictionary object (this is the dictionary Cl<01>UUT<03><><07>bjdreferenced by the <05> <09>func_globals attribute of functions defined in the module). Attribute <07><01>UUT<03><><07>be[references are translated to lookups in this dictionary, e.g. <05>m.x is equivalent to ` <01>UUT<03><><07><05>hoYm.__dict__["x"]. A module object does not contain the code object used to initialize <20><01>UUT<03><>@<07>e Dthe module (since it isn<73>t needed once the initialization is done).
nt<01>UUT<03><> <07><07>bAttribute assignment update the module<6C>s name space dictionary, e.g. <20><><05>m.x=1<1B><> is equiv<01>UUT<03><>@<07><07>*alent to <20><><05>m.__dict__["x"] = 1<1B><>.
<01>UUT<03><>(<07>odeSpecial read-only attribute: <05> <09>__dict__ is the dictionary object that is the module<6C>s name s<01>UUT<03><>H<07><><7F> space. <09>
ule U UT<03><>(<07> ioPredefined (writable) attributes: <05> <09>__name__ is the module name; <05> <09>__doc__ is the module<6C>s trU
1997-05-08 23:39:55 +00:00
UT<03><><07>ecldocumentation string, or <05>None if unavailable; <05> <09>__file__ is the pathname of the file from ed#UUT<03><><07>ncawhich the module was loaded, if it was loaded from a file. The <05>__file__ attribute is not e0UUT<03><><07>d ]present for C modules that are statically linked into the interpreter; for extension modules i=UUT<03><>@<07>odZloaded dynamically from a shared library, it is the pathname of the shared library file.
PUUT<03><>*<07><05><>tClasses  <09>Class objects are created by class definitions ( <09>See <20>Class definitions<6E> on page51. <09>). A class e.]UUT<03><><07>_has a name space implemented by a dictionary object. Class attribute references are translated eSpjT<6A>UT<03><><07>trkto lookups in this  <09>dictionary, e.g. <20><><05>C.x<1B><> is translated to <20><><05>C.__dict__["x"]<1B><>. When <09>wT<77>UT<03><><07><07>gthe attribute name is not found there, the  <09>attribute search continues in the base classes. The he <02>T<EFBFBD>UT<03><><07>UTcsearch is depth-first, left-to-right in the order of their occurrence in the base class list. When amecH<01><02><02>Ohh cH<01><02>l <0E><><07>__fd<02>M<0E>d <03>atreL<>H<01><02>CN rxtL<>H<01><02>z<><7A>UT--amically l-UTUT<03><><07> oga  <09>class attribute reference would yield a user-defined function object, it is transformed into deURUT<03><><07>Sean unbound user-defined method object (see above). The <05> <09>im_class attribute of this method b!UPUT<03><><07>ec`object is the class in which the function object was found, not necessarily the class for which on.UNUT<03><>H<07>x0the attribute reference was initiated.  <09>
1997-05-08 23:39:55 +00:00
. ?ULUT<03><>h<07><><7F>fClass  <09>attribute assignments update the class<73>s dictionary, never the dictionary of a base class.
PUJUT<03><>h<07>UTcA  <09>class object can be called as a function (see above) to yield a class instance (see below).
liaUHUT<03><>(<07>eSpecial read-only attributes: <05> <09>__dict__ is the dictionary that is the class<73>s name space; fnUFUT<03><><07><05>i <09>__name__ is the class name; <05> <09>__bases__ is a tuple (possibly empty or a singleton) cont{UDUT<03><>@<07><><7F>Ttaining the base classes, in the order of their occurrence in the base class list.
1997-05-08 23:39:55 +00:00
<00>UBUT<03><>(<07>e pPredefined (writable) attribute: <05> <09>__doc__ is the class<73>s documentation string, or <05>None if unse<00>U@UT<03><>@<07>bj defined.
o<00>U>UT<03><>(<07><05>m_vClass instances A  <09>class instance is created by calling a class object as a function (see above). A class <00>U<UT<03><><07>clYinstance has a name space implemented as a dictionary, which is the first place where inL<00>U:UT<03><><07>Clhstance attributes are searched. When an  <09>attribute is not found there, the search continues with UT<00>U8UT<03><><07><>cthe class attributes. If a class attribute is found that is a user-defined function object (and in UT<00>U6UT<03><><07>ia^no other case), it is transformed into an unbound user-defined method object (see above). The <00>U4UT<03><><07><05>[im_class attribute of this method object is the class in which the function object was ing<00>U2UT<03><><07>UTbfound, not necessarily the class of the instance for which the attribute reference was initiated. U0UT<03><><07>e eIf no class attribute is found, and the object<63>s class has a <05> <09>__getattr__ method, that is U.UT<03><>@<07>UTcalled to satisfy the lookup.
%U,UT<03><> <07>s ]Attribute assignments and deletions update the instance<63>s dictionary, never a class<73>s dictio 2U*UT<03><><07>U<nnary. If the class has a <05> <09>__setattr__ or <05> <09>__delattr__ method, this is called instead of ?U(UT<03><>@<07>st+updating the instance dictionary directly.
atPU&UT<03><>(<07>iClass instances can pretend to be  <09> <09>numbers,  <09>sequences,  <09>mappings, or callable objects, and n]U$UT<03><><07>ef\override various other special operations, if they have methods with certain special names. n jU"UT<03><>J<07>ed/See  <09><1C>Special method names<65> on page18 <09>.
<EFBFBD>{U UT<03><>(<07>rinSpecial attributes: <05> <09>__dict__ yields the attribute dictionary; <05> <09>__class__ yields the in<01>UUT<03><><07> oYstance<63>s class. In some implementations these may be assigned a new value; the new value <01>UUT<03><>@<07> f*must have the same type as the old value.
<01>UUT<03><>(<07><05>ho{FilesA  <09>file object represents an open file. File objects are created by the <05> <09>open() built-in function, ate<01>UUT<03><><07>ctoand also by <05>os <09>.popen(), <05>os. <09>fdopen() and the <05> <09>makefile() method of socket ob__<01>UUT<03><><07>odXjects (and perhaps by other functions or methods provided by extension modules). The oby.<01>UUT<03><><07><07>{jects <05>sys.<05> <09>stdin, <05>sys.<05> <09>stdout and <05>sys.<05> <09>stderr are initialized to file objects <07><01>UUT<03><><07>io_corresponding to the interpreter<65>s standard input, output and error streams. See the Python Lied<01>UUT<03><>@<07> m<brary Reference for complete documentation of file objects.
at<01>UUT<03><>(<07><05>__vInternal types A few types used  <09>internally by the interpreter are exposed to the user. Their definitions  U UT<03><><07>on]may change with future versions of the interpreter, but they are mentioned here for completepU
UT<03><>@<07>.
ness.
<03><>)UUT<03><>(<07><05>{Code objects  <09>Code objects represent <05> <09>byte-compile executable Python code, or <05> <09>bytecode. The <03><>6UUT<03><><07> b`difference between a code object and a function object is that the  <09>function object contains obCUUT<03><><07><07>Yan explicit reference to the function<6F>s globals (the name space dictionary of the module oPUUT<03><><07><07>Yin which it was defined), while a code object contains no context; also the default argur]UUT<03><><07>edZment values are stored in the function object, not in the code object (because they reprejT<6A>UT<03><><07>stYsent values calculated at run-time). Unlike function objects, code objects are immutable nwT<77>UT<03><>@<07>atGand contain no references (directly or indirectly) to mutable objects.
allL<>H<01><02><02>OrThL<>H<01><02>l<0E><><07>verd<02>Mied<03>UT<00><>cH<01><02>GN o ocH<01><02><02><><EFBFBD>bj00yte-compab0UTUT<03><>(<07>b`Special read-only attributes: <05> <09>co_argcount is the number of positional arguments (ins URUT<03><><07>io`cluding arguments with default values); <05> <09>co_nlocals is the number of local variables e !UPUT<03><><07>f ^used by the function (including arguments); <05> <09>co_varnames is a tuple containing the .UNUT<03><><07>ulanames of the local variables (starting with the argument names); <05> <09>co_code is a string ;ULUT<03><><07>e`representing the sequence of bytecode instructions; <05> <09>co_consts is a tuple containing reHUJUT<03><><07>UTdthe literals used by the bytecode; <05> <09>co_names is a tuple containing the names used by the UUHUT<03><><07>Tbytecode; <05> <09>co_filename is the filename from which the code was compiled; bUFUT<03><><07><05>] <09>co_flags is an integer encoding a number of flags for the interpreter. The following ooUDUT<03><><07><><7F>dflag bits are defined: bit 2 is set if the function uses the <20><05>*arguments<1B><> syntax to accept tr|UBUT<03><><07>_aSan arbitrary number of positional arguments; bit 3 is set if the function uses the ar<00>U@UT<03><><07>lt\<5C><><05>**keywords<1B><> syntax to accept arbitrary keyword arguments; other bits are used in b<00>U>UT<03><><07><07>bternally or reserved for future use. The first item in <05> <09>co_consts is the documentation <00>U<UT<03><><07> (bstring of the function, or <05>None if undefined. To find out the first line number of a func<00>U:UT<03><><07> bUtion, you have to disassemble the bytecode instructions; the standard library module T<00>U8UT<03><><07><05>d acodehack defines a function <05> <09>getlineno() that returns the first line number of a <20><00>U6UT<03><>@<07><>code object.
1997-05-08 23:39:55 +00:00
<00>U4UT<03><>(<07><05>e `Frame objects  <09>Frame objects represent execution frames. They may occur in traceback oba <00>U2UT<03><>@<07>r jects (see below).
fol<00>U0UT<03><>(Y<><7F>jSpecial read-only attributes: <05> <09>f_back is to the previous  <09>stack frame (towards the caller), U.UT<03><>Y<07>kor <05>None if this is the bottom stack frame; <05> <09>f_code is the code object being executed in ltU,UT<03><>Ykthis frame; <05> <09>f_locals is the dictionary used to look up locals variables; <05> <09>f_globals re"U*UT<03><>Yus]is used for global variables; <05> <09>f_builtins is used for built-in (intrinsic) names; /U(UT<03><>Y<05><05>] <09>f_restricted is a flag indicating whether the function is executing in restricted ex <U&UT<03><>Yemkecution mode; <05> <09>f_lineno gives the current line number and <05> <09>f_lasti gives the precise ctiIU$UT<03><>@YnoPinstruction (this is an index into the instruction string of the code object).
ZU"UT<03><>(<07>e lSpecial writable attributes: <05> <09>f_trace, if not <05>None, is a function called at the start of <20><>gU UT<03><>H<07>ee>each source code line (this is used by the  <09>debugger).
zUUT<03><>(<07><05> ic
Traceback objects  Traceback objects represent a stack trace of an exception. A traceback is<01>UUT<03><><07>frXobject is created when an exception occurs. When the search for an exception handler un f<01>UUT<03><><07>caYwinds the execution stack, at each unwound level a traceback object is inserted in front T<01>UUT<03><><07>se`of the current traceback. When an exception  <09>handler is entered, the stack  <09>trace is made <20><><01>UUT<03><>
<07>stdavailable to the program. ( <09>See <20>The try statement<6E> on page49. <09>) It is accessible as em<01>UUT<03><><07><05><>O <09>sys.exc_traceback, and also as the third item of the tuple returned by pre<01>UUT<03><><07><05><><EFBFBD>Ysys.exc_info(). The latter is the preferred interface, since it works correctly when
<01>UUT<03><><07>e Wthe program is using multiple threads. When the program contains no suitable exception lle<01>UUT<03><><07><><7F>^handler, the stack trace is printed on the standard error stream; if the interpreter is inter<01>U UT<03><>H<07>ebQactive, it is also made available to the user as <05> <09>sys.last_traceback.
eU
UT<03><>(<07><><7F>dSpecial read-only attributes: <05> $tb_next is the next level in the stack trace (towards the U
UUT<03><><07>wieframe where the exception occurred), or <05>None if there is no next level; <05> (tb_frame <20>UUT<03><><07>nt`points to the execution frame of the current level; <05> )tb_lineno gives the line number <07>'UUT<03><><07> t_where the exception occurred; <05> <09>tb_lasti indicates the precise instruction. The line <03><>4UUT<03><><07>exZnumber and last instruction in the traceback may differ from the line number of its frame AUUT<03><><07>jobject if the exception occurred in a <05> <09>try statement with no matching <05>except clause or NT<4E>UT<03><>@<07>re!with a <05>finally clause.
uaT<61>UT<03><>(<07>le<00>
<05> <09><05>
Slice objects Slice objects are used to represent slices when <05> <09>extended slice syntax is used (this QacnT<6E>UT<03><><07>adZis a slice using two colons, or multiple slices or  <09>ellipses separated by commas, e.g. {T<>UT<03><><07><05>: \a[i:j:step], <05>a[i:j,k:l], or <05>a[...,i:j]). They are also created by the fr<02>T<EFBFBD>UT<03><>@<07>pt#built-in <05>slice() function.
re cH<01><02><02>OUTcH<01><02>l <0E><> <07>veldMe<07>  <03>e e L<>H<01><02>KN datL<>H<01><02>j<><6A>ti**<03><><07> nd*UTUT<03><> <07>ralSpecial read-only attributes: <05>start is the lowerbound; <05>stop is the upperbound; <05>step a URUT<03><>@<07>atXis the step value; each is <05>None if omitted. These attributes can have any type.
/UP UT<04><>h<07>}UT <09>Special method names
1997-05-08 23:39:55 +00:00
LUNUT<03><> <07>seThis section describes how user-defined classes can customize their behavior or emulate the behavior cYULUT<03><><07>adhof other object types. In the following, if a class defines a particular method, any class derived from <07>fUJUT<03><>@<07>:it is also understood to define that method (implicitly).
UHUT<03><> <07>freA class can implement certain operations that are invoked by special syntax (such as arithmetic oper<00>UFUT<03><><07>hations or subscripting and slicing) by defining methods with special names. For instance, if a class de <00>UDUT<03><><07>e }fines a method named <05> <09>__getitem__, and <05>x is an instance of this class, then <05>x[i] is equivalent to *<00>UBUT<03><><07><05>rapx.__getitem__(i). (The reverse is not true; e.g. if <05>x is a list object, <05>x.__getitem__(i) is UR<00>U@UT<03><><07>isinot equivalent to <05>x[i].) Except where mentioned, attempts to execute an operation raise an excepT<00>U>UT<03><>@<07>od,tion when no appropriate method is defined.
1997-05-08 23:39:55 +00:00
cr<00><><EFBFBD>`<05>neBasic customization
e <00>U<UT<03><>(<07><05>em` <09>__init__(self, [args...]) Called when the instance is created. The arguments are those ne<00>U:UT<03><><07>homthat were passed to the class  <09>constructor expression. If a base class has an <05>__init__ method HU8UT<03><><07>A dthe derived class<73>s <05>__init__ method must explicitly call it to ensure proper initialization UFU6UT<03><><07>at-of the base class part of the instance, e.g. e!U4UT<03><>@<07> n1<><31><05>BaseClass.__init__(self,[args...])<1B><>.
<EFBFBD>4U2UT<03><>(<07><05>odp <09>__del__(self) Called when the instance is about to be destroyed. If a base class has a <05>__del__ UBAU0UT<03><><07>x.dmethod the derived class<73>s <05>__del__ method must explicitly call it to ensure proper deletion NU.UT<03><><07><><7F>_of the base class part of the instance. e.g. <20><><05>BaseClass.__del__(self)<1B><>. Note that it on [U,UT<03><><07>U>`is possible (though not recommended!) for the <05>__del__ method to postpone destruction of izhU*UT<03><><07><><7F>`the instance by creating a new reference to it. It may then be called at a later time when this e uU(UT<03><><07><><7F>cnew reference is deleted. It is not guaranteed that <05>__del__ methods are called for objects ini<01>U&UT<03><>@<07>U8-that still exist when the interpreter exits.
t<01>U$UT<03><>(<07><05><07>rProgrammer<65>s note: <20><><05> <09>del <05>x<1B><> doesn<73>t directly call <05>x.__del__() <20> the former decre<01>U"UT<03><><07><07>kments the  <09>reference count for <05>x by one, and the latter is only called when its reference count hen<01>U UT<03><><07>boZreaches zero. Some common situations that may prevent the reference count of an object to <01>UUT<03><><07><05>bgo to zero include: circular references between objects (e.g. a doubly-linked list or a tree data <01>UUT<03><><07>f ]structure with parent and child pointers); a reference to the object on the stack frame of a s<01>UUT<03><><07>nocfunction that caught an exception (the traceback stored in <05> <09>sys.exc_traceback keeps the in<01>UUT<03><><07> a]stack frame alive); or a reference to the object on the stack frame that raised an unhandled e<01>UUT<03><><07>et`exception in interactive mode (the traceback stored in <05> <09>sys.last_traceback keeps the U8<01>UUT<03><><07> w`stack frame alive). The first situation can only be remedied by explicitly breaking the cycles; UUT<03><><07>y bthe latter two situations can be resolved by storing <05>None in <05>sys.exc_traceback or UUT<03><>@<07><05>ansys.last_traceback.
d &UUT<03><> <07><05> cbWarning: due to the precarious circumstances under which <05>__del__ methods are invoked, 3U UT<03><><07>o ^exceptions that occur during their execution are <05>ignored, and a warning is printed to @U
UT<03><><07><05> d_sys.stderr instead. Also, when <05>__del__ is invoked is response to a module being de thMUUT<03><><07> sdleted (e.g. when execution of the program is done), other globals referenced by the <05>__del__ baZUUT<03><><07>in`method may already have been deleted. For this reason, <05>__del__ methods should do the absegUUT<03><><07>U^solute minimum needed to maintain external invariants. <09> Python 1.5 guarantees that globals L<>H<01><02>  Otk L<>H<01><02>l<0E><>#<07> d!M<0E>y ##<03>s n cH<01><02>O"N! s.ecH<01><02><02><><EFBFBD>U--st_trace# U-UTUT<03><><07>Zwhose name begins with a single underscore are deleted from their module before other gloURUT<03><><07>ex_bals are deleted; if no other references to such globals exist, this may help in assuring that UT!UPUT<03><>@<07>st\imported modules are still available at the time when the <05>__del__ method is called.
U4UNUT<03><>(<07><05>lev <09>__repr__(self) Called by the <05> <09>repr() built-in function and by  <09>string conversions ( <09>reverse AULUT<03><><07>dy[quotes) to compute the <20>official<61> string representation of an object. This should normally <07>NUJUT<03><>@<07>umalook like a valid Python expression that can be used to recreate an object with the same value.
aUHUT<03><>(<07><05>| <09>__str__(self) Called by the <05> <09>str() built-in function and by the <05> <09>print statement compute the nUFUT<03><><07>s k<><6B>informal<61><6C> string representation of an object. This differs from <05> <09>__repr__ in that it doesn<73>t {UDUT<03><><07>-]have to look like a valid Python expression: a more convenient or concise representation may b<00>UBUT<03><>@<07>URbe used instead.
a<00>U@UT<03><>(<07><05> nd 4__cmp__(self, other) Called by all comparison operations. Should return a negative integer rt<00>U>UT<03><><07>ll<00>if <05>self<05><<05>other, zero if <05>self<05>==<05>other, a positive integer if <05>self<05>><05>other. If no <00>U<UT<03><><07><05><>\__cmp__ method is defined, class instances are compared by object identity (<28>address<73>). r<00>U:UT<03><><07>n a(Note: the restriction that exceptions are not propagated by <05>__cmp__ has been removed in b<00>U8UT<03><>@<07> a Python 1.5)
th<00>U6UT<03><>(<07><05>UHn <09>__hash__(self) Called for the key object for  <09>dictionary operations, and by the built-in function <00>U4UT<03><><07><05>coe <09>hash(). Should return a 32-bit integer usable as a hash value for dictionary operations. The <20><00>U2UT<03><><07>in[only required property is that objects which compare equal have the same hash value; it is co U0UT<03><><07>e Xadvised to somehow mix together (e.g. using exclusive or) the hash values for the compop_U.UT<03><><07>enents of the object that also play a part in comparison of objects. If no <05>__hash__ method is l#U,UT<03><><07><>adefined, class instances are hashed by object identity (<28><>address<73><73>). If a class does not define 0U*UT<03><><07>Ifna <05>__cmp__ method it should not define a <05>__hash__ method either; if it defines <05>__cmp__ =U(UT<03><><07><><7F>dbut not <05>__hash__ its instances will not be usable as dictionary keys. If a class defines mud JU&UT<03><><07><07>etable objects and implements a <05>__cmp__ method it should not implement <05>__hash__ since tWU$UT<03><><07> a]the dictionary implementation requires that a key<65>s hash value is immutable (if the object<63>s rdU"UT<03><>H<07>vaFhash value changes, it will be in the wrong hash bucket). <09><05> <09>
wU UT<03><> <07><05>bj`__nonzero__(self) Called to implement truth value testing; should return 0 or 1. When this ow<01>UUT<03><><07>. kmethod is not defined, <05> <09>__len__ is called, if it is defined (see below). If a class defines neia p<01>UUT<03><>@<07>ofUther <05>__len__ nor <05>__nonzero__, all its instances are considered true.
c<01><><EFBFBD>`<07><05>bjCustomizing attribute access
a<01>UUT<03><>(<07>fijThe following methods can be defined to customize the meaning of  <09>attribute access (use of, assign<01>UUT<03><><07>cmlment to, or deletion of <05>x.<05>name) for class instances. For performance reasons, these methods are a<01>UUT<03><><07>d gcached in the class object at class definition time; therefore, they cannot be changed after the class _ha<01>UUT<03><>@<07>definition is executed.
io<01>UUT<03><>(<07><05>n d <09>__getattr__(self, name) Called when an attribute lookup has not found the attribute in the es UUT<03><><07>e uusual places (i.e. it is not an instance attribute nor is it found in the class tree for <05>self). <05>name hUUT<03><><07>. \is the attribute name. This method should return the (computed) attribute value or raise an is%U UT<03><>H<07><05>w)"
AttributeError exception.
6U
UT<03><> <07> ]Note that if the attribute is found through the normal mechanism, <05>__getattr__ is not <20>CUUT<03><><07>at`called. (This is an intentional asymmetry between <05>__getattr__ and <05>__setattr__.) g PUUT<03><><07>te^This is done both for efficiency reasons and because otherwise <05>__setattr__ would have ]UUT<03><><07> pbno way to access other attributes of the instance. Note that at least for instance variables, you jUUT<03><><07>re`can fake total control by not inserting any values in the instance attribute dictionary (but inUwUUT<03><>@<07> )stead inserting them in another object).
a<02>T<EFBFBD>UT<03><>(<07><05> h^ <09>__setattr__(self, name, value) Called whenever an attribute assignment is attempted. cH<01><02>#O!r fcH<01><02>l <0E><> )""<07>attd<11>$M(mp&&<03>ai acH<01><02><11>%N$ rcH<01><02><02><><EFBFBD><04><>..he attri& th.UTUT<03><><07>, eThe <05>sequence argument can have any type. The return value should be <05>None. Same notes URUT<03><>@<07>d 9for <05>i and <05>j as for <05>__getslice__.
b'UPUT<03><>(<07><05> rn 3__delslice__(self, i, j) Called to implement deletion of <05>self[i:j]. Same notes for <05>i 4UNUT<03><>@<07>e.+and <05>j as for <05>__getslice__.
ou MULUT<03><> <07>refNotice that these methods are only invoked when a single slice with a single colon is used. For slice ZUJUT<03><><07>stzoperations involving <05>
extended slice notation, <05>__getitem__, <05>__setitem__ or <05>__delitem__ gUHUT<03><>@<07>is is called.
c<00><><EFBFBD>`<07><05>Emulating numeric types
<00>UFUT<03><> <07>`The following methods can be defined to emulate numeric objects. Methods corresponding to opera&<00>UDUT<03><><07> altions that are not supported by the particular kind of number implemented (e.g.,  Ebitwise operations for <00>UBUT<03><>@<07>UT0non-integral numbers) should be left undefined.
n <00>U@UT<03><>h<07><05> r
__add__(self, right)
<00>U>UT<03><>h<07><05>UR F__sub__(self, right)
<00>U<UT<03><>h<07><05>or G__mul__(self, right)
<00>U:UT<03><>h<07><05>__ H__div__(self, right)
<00>U8UT<03><>h<07><05>le I__mod__(self, right)
U6UT<03><>h<07><05> ! J__divmod__(self, right)
U4UT<03><>h<07><05>ic K__pow__(self, right)
"U2UT<03><>h<07><05>e ! L__lshift__(self, right)
g/U0UT<03><>h<07><05>#! M__rshift__(self, right)
T<U.UT<03><>h<05>at N__and__(self, right)
IU,UT<03><>h<05>,  O__xor__(self, right)
VU*UT<03><>(<07><05>de ,__or__(self, right) <07>cU(UT<03><><07>aThese functions are called to implement the 
binary arithmetic operations (+, -, *, /, %, divdpU&UT<03><><07>nu\mod(), pow(), <<, >>, &, ^, |). For instance: to evaluate the expression x+y, where x is an rt}U$UT<03><>@<07>arHinstance of a class that has an __add__ method, x.__add__(y) is called.
<EFBFBD><EFBFBD><01>U"UT<03><>h<05>gr .__radd__(self, left)
<01>U UT<03><>h<07><05><><EFBFBD> :__rsub__(self, left)
<01>UUT<03><>h<07><05><><EFBFBD> ;__rmul__(self, left)
<01>UUT<03><>h<07><05><><EFBFBD> <__rdiv__(self, left)
<01>UUT<03><>h<07><05><><EFBFBD> =__rmod__(self, left)
<01>UUT<03><>h<07><05><><EFBFBD>! >__rdivmod__(self, left)
<01>UUT<03><>h<07><05><07> ?__rpow__(self, left)
<01>UUT<03><>h<07><05><><EFBFBD>! @__rlshift__(self, left)
<01>UUT<03><>h<07><05><07>! A__rrshift__(self, left)
UUT<03><>h<07><05><07> B__rand__(self, left)
UUT<03><>h<07><05><><EFBFBD> C__rxor__(self, left)
U UT<03><>(<07><05><><EFBFBD>g D__ror__(self, left)  These functions are called to implement the binary arithmetic operations ,U
UT<03><><07>ar<00>(<05>+, <05>-, <05>*, <05>/, <05>%, <05>divmod(), <05>pow(), <05><<, <05>>>, <05>&, <05>^, <05>|) with reversed operands. These functions 9UUT<03><><07><><7F>`are only called if the left operand does not support the corresponding operation. For instance: FUUT<03><><07>(sXto evaluate the expression x+y, where x is an instance of a class that does not have an  SUUT<03><>@<07><05>ef3__add__ method, <05>y.__radd(x) is called.
)fUUT<03><>h<07><05><07> /__neg__(self)
lefsUUT<03><>h<07><05><><EFBFBD> 0__pos__(self)
(se<02>T<EFBFBD>UT<03><>h<07><05>U 1__abs__(self)
pow<02>T<EFBFBD>UT<03><>
h<07><05>
<00> 2__invert__(self)  Called to implement the unary arithmetic operations (<05>-, <05>+, <05>abs() and <05>~).
 cH<01><02><11>&O$<13><00><>cH<01><02>l <0E><>),%%<07>or_d<02>'Ml t))<03>thtiL<>H<01><02><02>(N' +L<>H<01><02><02><><EFBFBD>, **<2A>divmod)
w(*UTUT<03><><07>bThis is called instead of the normal mechanism (i.e. instead of storing the value in the instance URUT<03><>@<07>hebdictionary). <05>name is the attribute name, <05>value is the value to be assigned to it.
%UPUT<03><> <07>esfIf <05>__setattr__ wants to assign to an instance attribute, it should <05>not simply execute 2UNUT<03><><07>(xh<><68><05>self.<05>name<05> = value<1B><> <20> this would cause a recursive call to itself. Instead, it should )?ULUT<03><><07><><7F>@insert the value in the dictionary of instance attributes, e.g. veLUJUT<03><>H<07>al-<2D><><05>self. <09>__dict__[name]=value<1B><>.
s_UHUT<03><>(\<05>g <09>__delattr__(self, name) Like <05>__setattr__ but for attribute deletion instead of assignlUFUT<03><>@\ment.
<00><><EFBFBD>`<07><05>Emulating callable objects
<00>UDUT<03><>(<07><05>)h <09>__call__(self, [args...]) Called when the instance is <20>called<65> <09> as a function; if this meth<00>UBUT<03><><07>Xod is defined, <05>x(arg1, arg2, ...) is a shorthand for <05>x.__call__(arg1, arg2, i.<00>U@UT<03><>@<07><05>in
...).
<00><><EFBFBD>`<07><05>UR%Emulating sequence and mapping types
<00>U>UT<03><> tecThe following methods can be defined to emulate sequence or mapping objects. The first set of methwan<00>U<UT<03><> iiods is used either to emulate a sequence or to emulate a mapping; the difference is that for a sequence, uU:UT<03><>ld<00>the allowable keys should be the integers <05>k for which 0 <05><= <05>k <05>< <05>N where <05>N is the length of the seJ
U8UT<03><><><7F>gquence, and the method <05>__getslice__ (see below) should be defined. It is also recommended that <05>U6UT<03><>t tmappings provide methods <05>keys, <05>values and <05>items behaving similar to those for Python<6F>s stants'U4UT<03><><07>pdard dictionary objects; mutable sequences should provide methods <05>append, <05>count, <05>index, UB4U2UT<03><>od}<05>insert, <05>sort, <05>remove and <05>reverse like Python standard list objects. Finally, sequence types AU0UT<03><>at`should implement addition (meaning concatenation) and multiplication (meaning repetition) by deatNU.UT<03><>inxfining the methods <05>__add__, <05>__radd__, <05>__mul__ and <05>__rmul__ described below; they should ; [U,UT<03><>@th<not define <05>__coerce__ or other numerical operators.
honU*UT<03><>(<07><05>s p
__len__(self) Called to implement the built-in function <05>len(). Should return the length of the <20><>{U(UT<03><><07>anlobject, an integer <05>>= 0. Also, an object that doesn<73>t define a <05>
__nonzero__() method and <01>U&UT<03><>@<07>vi]whose <05>__len__() method returns zero is considered to be false in a Boolean context.
s<01>U$UT<03><>(<07><05><><EFBFBD>g <09>__getitem__(self, key) Called to implement evaluation of <05>self[key]. Note that the spe, <01>U"UT<03><><07>U2_cial interpretation of negative keys (if the class wishes to emulate a sequence type) is up to tan<01>U UT<03><>@<07> F the <05>__getitem__ method.
<EFBFBD><EFBFBD><01>UUT<03><>(<07><05>mpa <09>__setitem__(self, key, value) Called to implement assignment to <05>self[key]. Same <20><01>UUT<03><>@<07>he!note as for <05>__getitem__.
d<01>UUT<03><>(<07><05>_d
__delitem__(self, key) Called to implement deletion of <05>self[key]. Same note as for _<01>UUT<03><>@<07><05>ic__getitem__.
* UUT<03><>`<07>~
3Additional methods for emulation of sequence types
fu$UUT<03><> bThe following methods can be defined to further emulate sequence objects. For immutable sequences 1UUT<03><>t fmethods, only <05>__getslice__ should be defined; for mutable sequences, all three methods should >UUT<03><>@de be defined.
e QUUT<03><>(<07><05>xtd
__getslice__(self, i, j) Called to implement evaluation of <05>self[i:j]. The returned ey^U UT<03><><07>he|object should be of the same type as <05>self. Note that missing <05>i or <05>j in the 
slice expression ankU
UT<03><><07> Feare replaced by 0 or <05>len(self), respectively, and <05>len(self) has been added (once) to xUUT<03><>@<07>nmqoriginally negative <05>i or <05>j by the time this function is called (unlike for <05>__getitem__).
_<02>UUT<03><>(<07><05>y)a
__setslice__(self, i, j, sequence) Called to implement assignment to <05>self[i:j]. _L<>H<01><02><02>)O'ialL<>H<01><02>l<0E><>#&((<07>d<11>*Muhe,,<03>. r L<>H<01><02><11>+N* eodL<>H<01><02>I<><49>&&for muta,  a&UTUT<03><>h<07><05>U 6__int__(self)
nedURUT<03><>h<07><05><07> 7__long__(self)
f,!UPUT<03><>(<07><05> tx 8__float__(self)  Called to implement the built-in functions <05>int(), <05>long() and <05>float(). s.UNUT<03><>@<07> m/Should return a value of the appropriate type.
e eAULUT<03><>h<05>UT 9__oct__(self)
d bNUJUT<03><>(<05>f)t P__hex__(self)  Called to implement the built-in functions <05>oct() and <05>hex(). Should return a  [UHUT<03><>@e string value.
nUFUT<03><>(<07><05>kea 5__coerce__(self, other) Called to implement <20>mixed-mode<64> 
numeric arithmetic. Should d{UDUT<03><><07>gnieither return a 2-tuple containing <05>self and <05>other converted to a common numeric type, or <00>UBUT<03><><07><05>&cNone if no conversion is possible. When the common type would be the type of <05>other, it <20><00>U@UT<03><><07>his sufficient to return <05>None, since the interpreter will also ask the other object to attempt a <20><><00>U>UT<03><><07>t_^coercion (but sometimes, if the implementation of the other type cannot be changed, it is use<00>U<UT<03><>@<07>ll2ful to do the conversion to the other type here).
<00>U:UT<03><>(
<05>ndl
Coercion rules: to evaluate x <05>op y, the following steps are taken (where <05>__op__ and UT<00>U8UT<03><>
<05>)u__rop__ are the method names corresponding to <05>op, e.g. if <05>op is <20><05>+<1B>, <05>__add__ and h<00>U6UT<03><>
<05>et]__radd__ are used). If an exception occurs at any point, the evaluation is abandoned and <00>U4UT<03><>@
meexception handling takes over.
met<00>U2UT<03><> UTn0.If x is a string object and <05>op is the modulo operator (<05>%), the string formatting operation U0UT<03><>@<><7F>@(see [Ref:XXX]) is invoked and the remaining steps are skipped.
ypU.UT<03><>`e 1.If x is a class instance:
T-U,UT<03><> <07>ufW1a.If x has a <05>__coerce__ method: replace x and y with the 2-tuple returned by tte:U*UT<03><>@<07><05><><EFBFBD>Jx.__coerce__(y); skip to step 2 if the coercion returns <05>None.
MU(UT<03><>` itI1b.If neither x nor y is a class instance after coercion, go to step 3.
r`U&UT<03><> 
`1c.If x has a method <05>__op__, return <05>x.__op__(y); otherwise, restore x and y to _mU$UT<03><>@U8their value before step 1a.
ar<01>U"UT<03><>` c2.If y is a class instance:
.<01>U UT<03><> <>W2a.If y has a <05>__coerce__ method: replace y and x with the 2-tuple returned by tio<01>UUT<03><>@<05>inBy.__coerce__(x); skip to step 3 if the coercion returns None.
<01>UUT<03><>` r.I2b.If neither x nor y is a class instance after coercion, go to step 3.
m<01>UUT<03><>  <>]2b.If y has a method <05>__rop__, return <05>y.__rop__(x); otherwise, restore x and e<01>UUT<03><>@ re!y to their value before step 2a.
.<01>UUT<03><>`
ns<3.We only get here if neither x nor y is a class instance.
 <01>UUT<03><>`anY3a.If <05>op is <20><05>+<1B> and x is a sequence, sequence concatenation is invoked.
 UUT<03><> ref3b.If <05>op is <20><05>*<1B> and one operand is a sequence and the other an integer, sequence repUUT<03><>@UTetition is invoked.
h,UUT<03><> opP3c.Otherwise, both operands must be numbers; they are coerced to a common type 9U UT<03><>@beAif possible, and the numeric operation is invoked for that type.
.FU
UT<03><>`<07><> aL<>H<01><02><11>,O*le L<>H<01><02>l<0E><>&++<07>By.d<14>6Meio7;<03><00><> L<>$<01> <14>7N96tceL<>$<01> l<0E><>88<07>y hL<>$<01> <14>8N6 _p_L<>$<01>  es@ re7al`<05>UT `
L<><02><01> <14>9N7;6s L<><02><01> l<0E><>::<07>s <20>L<><02><01> <14>:N6 nteL<><02><01>  <09><>U <05>op9<06><><06><>UUn<05>qu  W# X thL<>H<01><02><14>;O96UTL<>H<01><02>l<0E><><<<07>botL<>H<01><02><14><N6 do L<>H<01><02>
<EFBFBD><EFBFBD>UTe, and t;raUTUT<03><>eyp .IH
<EFBFBD><01><>Z<14>=O<03><03><11>z<01><>
<EFBFBD>l <0E><>>><07>IH
<EFBFBD><01><>Z<14>>N<03> <14>z<01><>
<EFBFBD> io<00><> =n<05>t [Running H/F 2 \ H<00><><EFBFBD><01>
<14>?N<03>A<03>h<00>@@ Single Linep_<01><14>@R?<01>7al<01>HZ<00><05><><14>AN?B<03><0E>N
TableFootnoteE<><45>Gx<47>R<><52> <19><14>BNA<03> E<><45>Gx<47>R<><52> <19>E<><45>PwE<><45>Pw<05>
TableFootnote<03><03><03>d<03><03>6Leftd<03><03><03><03><00><>Right<68>d<03><03><03>Firstd<03><03><00> Referenced<03><03> <00><><d<03><03><03> Nd<03><03><03>d<03><03><03> ad<03><03><03>UTd<03><03><03><00>d<03><03><03><11>d<03><03><03>d<03><03><03>!<00>d
<03><03><03>$ d <03><03><03>'d <03><03>*d<03><03> HIDDEN<05>J$$<00>@ <04><00> CBlockIndent. $$<00>@ <04><01><><00><00> <20> CBlockIndent. tn$$<00>@ <04><00> CBlockIndent. <00>f<19>#{T <04> 
TableTitleT:Table <n+>: . <00>f<19>$| <04> CellHeading. <00>f<19>%| <04>CellBody. <00>f<19>&| <04> CellFooting. - <00>@K~C <04> de- 3HeadingC:<n>.<n>.<n>.<+>\t. <00><>&fL  <04> Body. c$<00>@M<05>C<04> +>c  Chapter InitialCapsC:Chapter <+>:\t. $ <00>@N}C<04> $ 1Heading C:<n>.<+>\t. <00>@O <04>$|  FirstBody. $<00>@P <04>$
HangIndent. $$<00>@Q <04><00> CBlockIndent. 6$<00>@R <04>6<00> HangIndentLev2. 66<00>@S <04>@<00>
CBlockIndent2. Z6<00>@T  <04><01>Z HangIndentLev3. ZZ<00>@U <04><00>
CBlockIndent3. - <00>@V<05>C <04> @- 2HeadingC:<n>.<n>.<+>\t. <00>@W<05> <04><00> <01> Header. <00>@X<05>
<04><00> <01> Footer. ff<00>@Y<05> <04>  Bullet2<03>\t. $ <00>@ZC<04> $ 1Heading C:<n>.<+>\t. $<00>@[ <04>$ HangIndentCont.
<00>@]<04> <1C><> 1Heading*. ff<00>@^S <04>ff 1StepS:<1>.\t. +33<1C><><00>@_U <04>+33 1StepLev2U:<1>.\t. H9<><39><00>@`V <04>H 1StepLev3V:<1>.\t. 9<><39>9<><39>9<><39>
<00>@a <04>ff Abstract. <00>f<19>b <04> CellBodyC. - <00>@cC <04> - 2HeadingC:<n>.<n>.<+>\t.  <00>@d<04> @$ 2Heading*. - <00>@eC <04> <01>- 3HeadingC:<n>.<n>.<n>.<+>\t. <00>@f <04> +33 3Heading*. +33 <00>@gH <04> +33 4HeadingH:<n>.<n>.<n>.<+>\t. <00>@h <04> 2ff 4Heading*. +33 <00>@iH <04> 2ff 5HeadingH:<n>.<n>.<n>.<n>.<+>\t.  <00>@j <04> H 5Heading*. $$$<00>@k <04>ff Author. <00><>&fl  <04> Body. ff<00>@m <04>ff Bullet<03>\th. ff<00>@n <04>  Bullet2<03>\t. +33<1C><><00>@o <04>+33
BulletLev2<03>\t. H9<><39><00>@p <04>H
BulletLev3<03>\t. 66<00>@r <04><00> f
CBlockIndent2. $$<00>@s <04><00>
CBlockIndent3. ffff<00>@t <04>@<00> CBullet. +33+33<00>@u <04><00> CBullet2. HH<00>@v <04><01><00> CBullet3. <00>@w <04><00> Center. c$<00>@xC<04> c Chapter InitialCapsC:Chapter <+>:\t. $$$<00>@y<04> 
$ H l <00> <00> <00> <00>   D hB e<01> <01> 3<01> Chapter*. <00>@z
<04>
$ H l <00> <00> <00> <00>   D h <01> <01> <01>B eCode. ffff<00>@{ <04>H e<00> <00>    h <01> <01> CStep.
<00>@| <04>H <00> <00>   h <01> <01> Equation. <00>@} <04> eH <00> 3<00>  e h <01> <01> ETable. 9<><39>9<><39>9<><39><00>@~ <04>$ Extract. <00>@F <04> $ FigureF:Figure <+> . <00>@<05> <04>$ FirstBody. <00>@<05> <04>$ FlushL. $<00>@<05> <04>$ FlushR. v<> <00>@<05>
<04><16> Footnote. $<00>@<05> <04>$
HangIndent. 6$<00>@<05> <04>6 HangIndentLev2. Z6<00>@<05>  <04>Z HangIndentLev3. H<00>@<05>P<04> H Part P:PART <+>\t. <00>@<05><04> ff Part*. ff<00>@<05>S <04><01>ff StepS:<+>.\t. +33<1C><><00>@<05>U <04>+33 StepLev2U:<+>.\t. H9<><39><00>@<05>V <04>@H StepLev3V:<+>.\t. - <00>@<05> <04> -
SubHeading. <00>@<05>T <04> Table
T:Table <+> . HHH<00>@<05><04> Title. $<00>@<05> <04>$ HangIndentCont. y<05><05>
<00>3<EFBFBD><00>`fy<04>  CodeInput <00>ڝ<EFBFBD>z6<04> )<1A><>{<04>  <00>ڝ<EFBFBD>|<04><13>[}<04>  <13>[~<04>  <00>ڝ<EFBFBD><04> <13>[<05><04> <00><00><05>Code<00><05> Emphasis <00>ڝ<EFBFBD><05><04> yc<79>><05><04><13>[<05><04> <00><05> EquationVariables#<23><05><04>  InitialCaps
<00>ڝ<EFBFBD><05><04> <00>3<EFBFBD>)<1A><><05><04> Strong<13>[<05><04>  InitialCaps tu <0C><05><04>Emphasis i_mF<05><04>Code i_mF<05><04> )<1A><><05><04> StrongM}SMN<00>O<04><00>P<04><00>Q<04>R<04>AQF<00>A<04>ThinB<04>Medium<00>C<04><00>DoubleD<04>odeThick@E<04> Very Thin=M=<06><06><06> <06>AAAAAAAAAC#<04><04><04>H$%&[H$%&H$%&H$%&H$%&Format A <06>ABAAAAAB#<04><04><04>H$%&H$%&H$%&H$%&H$%&oFormat Bu<0E>u<0E><0E><0E>  
<04>CommentC5E56 <09> <09> <09>
<14> <09> a Y Z<1A> <09><03> e dde<1A> <09><03> g h<14> <09> d W X<14> <09> e [ \<1A> <09><03> i j <09><03> <09> <09>ro@ <09><03> <09> <09>d <09><03> <09> <09><1D> <09><03> <09> <09><04><04><04>d<04>Black<63>T!<04>WhiteddA<04><04>Reddd<08><04>GreenQdd <04>ThBlued<04>Cyand<04>Magentaded <04>Yellow Times-RomanA
Times-BoldHelvetica-Bold Helvetica&Courier& Courier-Bold Times-ItalicCourierATimes Helvetica
RegularRegularA BoldRegular<61>Italic <0B><>_<EFBFBD><5F>z<EFBFBD><1E><>%<25>-<2D><>`H<>W<>m<EFBFBD><6D><EFBFBD>m%<25>s]u<>ʨ҇<CAA8><D287>Q<EFBFBD><51><EFBFBD><EFBFBD><EFBFBD>~<7E><>ChNN<>1\Z<>n<EFBFBD><6E><1D>Շy<D587><79>SH<><48><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>K<EFBFBD><4B><EFBFBD><EFBFBD>^<5E><1A>mW6<57>9E`><3E><><EFBFBD><EFBFBD>7<EFBFBD>Ij~&<26><>Z<EFBFBD>sV6<56>1<EFBFBD>?:<3A>\<5C>ު<EFBFBD><DEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>P\<5C><>V<EFBFBD><56><EFBFBD>\d<>nr<6E>UY<55>>^<11><><12>ɕ<05><>z~i<>
<EFBFBD><EFBFBD>Z<EFBFBD>pydlj<6C><6A><1B>ĥ<EFBFBD><C4A5>H<EFBFBD>`<60><48><C3BA>yv%<25>T<EFBFBD><54>j&RA<52><0F><>p%Q<08><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD>`<60>g<EFBFBD>J<EFBFBD>jV<6A><k"<22>*C<><43>lg<6C>p<06>x<EFBFBD><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD>k9M<39>v<EFBFBD>tBދ<42>.Dž&p<><04><><0F>-g <0C>
<EFBFBD>y<EFBFBD><EFBFBD><EFBFBD>,h+<2B><><EFBFBD>?<3F><><EFBFBD>><pZ<70>q<1C><><EFBFBD>g<EFBFBD><67><EFBFBD>
+!1<07><><EFBFBD>ץ,<2C><03><1B><><EFBFBD>,DF<44><46>sM<73>߄lj˹<6A>E]<10><>ݪv<7F><76><EFBFBD>}2I
<EFBFBD><EFBFBD><EFBFBD>q<|i