%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python2.7/test/
Upload File :
Create Path :
Current File : //usr/local/lib/python2.7/test/test_deque.pyc

ó
Nêáac@s”ddlmZddlZddlmZmZddlZddlZddlZddl	Z
ddlZddlZdZ
d„Zdfd„ƒYZdfd	„ƒYZd
ejfd„ƒYZdejfd
„ƒYZdefd„ƒYZdefd„ƒYZdejfd„ƒYZdefd„ƒYZdejfd„ƒYZdZied6Zed„ZedkredeƒndS(iÿÿÿÿ(tdequeN(ttest_supportt	seq_testsi †ccst‚dVdS(Ni(tSyntaxError(((s+/usr/local/lib/python2.7/test/test_deque.pytfail
stBadCmpcBseZd„ZRS(cCs
t‚dS(N(tRuntimeError(tselftother((s+/usr/local/lib/python2.7/test/test_deque.pyt__eq__s(t__name__t
__module__R	(((s+/usr/local/lib/python2.7/test/test_deque.pyRst	MutateCmpcBseZd„Zd„ZRS(cCs||_||_dS(N(Rtresult(RRR
((s+/usr/local/lib/python2.7/test/test_deque.pyt__init__s	cCs|jjƒ|jS(N(RtclearR
(RR((s+/usr/local/lib/python2.7/test/test_deque.pyR	s
(R
RRR	(((s+/usr/local/lib/python2.7/test/test_deque.pyRs	t	TestBasiccBs^eZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d	„Zd
„Zd„Z
d„Zd
„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z!d „Z"d!„Z#d"„Z$e%j&Z&e%j'd#„ƒZ(RS($cCsyttddƒƒ}|jtdƒƒx$tddƒD]}|j|ƒq8Wx*ttddƒƒD]}|j|ƒqeW|jt|ƒtddƒƒ|jt	|ƒdƒgtdƒD]}|j
ƒ^q¾}|j|tdd	ƒƒ|jt|ƒtd	dƒƒgtdƒD]}|jƒ^q}|jƒ|j|td
dƒƒ|jt|ƒtd	d
ƒƒdS(NiûëÿÿixìÿÿiÈii8ÿÿÿiiXiúi2i–(
RtxrangeRtappendtreversedt
appendlefttassertEqualtlisttrangetlentpoplefttpoptreverse(Rtdtitlefttright((s+/usr/local/lib/python2.7/test/test_deque.pyttest_basicss%%
cCsÉ|jttddƒ|jttddƒttdƒƒ}t|ddƒ}|jt|ƒgƒ|jt|ƒdƒ|jt|ƒtddƒƒ|j|ttdƒdƒƒ|jdƒ|jt|ƒtd	d
ƒƒ|j	dƒ|jt|ƒtddƒƒ|j
dd
gƒ|jt|ƒtddƒƒ|jd	dgƒ|jt|ƒtddƒƒttd
ƒddƒ}|j|ƒt
jt
jƒtt
jdƒ}zF||I|jƒtt
jdƒ}|j|jƒt|ƒƒWd|jƒt
jt
jƒXttdƒddƒ}|jt|ƒdƒtt
jdƒ}zF||I|jƒtt
jdƒ}|j|jƒt|ƒƒWd|jƒt
jt
jƒXdS(Ntabciÿÿÿÿiþÿÿÿi
tmaxlenisdeque([7, 8, 9], maxlen=3)iiii	iiÈtwbtrbs%deque([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])(tassertRaisest
ValueErrorRtiterRRRtreprRRtextendt
extendleftRRtunlinktTESTFNtopentclosetreadtNone(RtitRtfo((s+/usr/local/lib/python2.7/test/test_deque.pyttest_maxlen2sJ




 


 
cCsÄttdƒƒ}t|ddƒ|jt|ƒgƒttdƒƒ}tddƒ}|j|ƒ|jt|ƒgƒttdƒƒ}tddƒ}|j|ƒ|jt|ƒgƒdS(NidR"i(R'RRRRR)R*(RR1R((s+/usr/local/lib/python2.7/test/test_deque.pyttest_maxlen_zero\s

cCs»|jtƒjdƒ|jtdƒjdƒ|jtdddƒjdƒ|jtdddƒjdƒ|jtdddƒjdƒ|jtƒtdƒ}d|_WdQXdS(NR!R"iiii
(RRR"R0R%tAttributeError(RR((s+/usr/local/lib/python2.7/test/test_deque.pyttest_maxlen_attributekscCsðxvdddddfD]]}t|ƒ}t|ƒ}x<dD]4}|j|j|ƒ|j|ƒ|||fƒq=WqW|jt|jƒ|jt|jddƒd	dd
„ƒY}tdd|ƒdgƒ}|jt|jdƒtdddgƒ}|jt|j|ƒƒddd
„ƒY}|ƒ}tddd|ddgƒ}||_|jt|jdƒtdgdƒ}x't
t|ƒƒD]}|jdƒq–W|jdƒ|j|jdƒdƒ|j|jdƒdƒdS(Nttabracadabrat
simsalabimiôR!tabcdefghijklmnopqrstuvwxyziit
BadComparecBseZd„ZRS(cSs
t‚dS(N(tArithmeticError(RR((s+/usr/local/lib/python2.7/test/test_deque.pyR	~s(R
RR	(((s+/usr/local/lib/python2.7/test/test_deque.pyR;}sitMutatingComparecBseZd„ZRS(cSs|jjƒtS(N(RRtTrue(RR((s+/usr/local/lib/python2.7/test/test_deque.pyR	…s
(R
RR	(((s+/usr/local/lib/python2.7/test/test_deque.pyR=„siiiiÿÿÿÿi(((
RRRtcountR%t	TypeErrorR<RRR0RRtrotate(RtsRtletterR;R=tmR((s+/usr/local/lib/python2.7/test/test_deque.pyt
test_countus.
6		
cCs^tdƒ}|jƒx³|tdƒtdƒtƒt|ƒgD]‡}|j||kt|ƒt|ƒkoƒt|ƒt|ƒkƒ|j||kt|ƒt|ƒkoÃt|ƒt|ƒkƒqAWttd
ƒ}x||D]t}xk|D]c}|j||kt|ƒt|ƒk||fƒ|j||kt|ƒt|ƒk||fƒ|j||kt|ƒt|ƒk||fƒ|j||kt|ƒt|ƒk||fƒ|j||kt|ƒt|ƒk||fƒ|j||kt|ƒt|ƒk||fƒ|jt||ƒtt|ƒt|ƒƒ||fƒqïWqâWdS(NtxabcR!tabR7tatbtbatxbatcba(	R7RHRIRGRJR!RKRFRL(RRRRttypetmaptcmp(RRtetargstxty((s+/usr/local/lib/python2.7/test/test_deque.pyttest_comparisons–s
1@E

111111cCsxtdƒ}|jt|jdƒ|jdƒ|jt|ƒtdƒƒ|j|ƒ|jt|ƒtdƒƒdS(NRHitbcdtabcdtabcdabcd(RR%R@R)RR(RR((s+/usr/local/lib/python2.7/test/test_deque.pyttest_extend§s

cCs\tdƒ}|d7}|jt|ƒtdƒƒ||7}|jt|ƒtdƒƒdS(NRHRURVRW(RRR(RR((s+/usr/local/lib/python2.7/test/test_deque.pyt	test_iadd¯s


cCsÛtdƒ}|jt|jdƒ|jdƒ|jt|ƒttdƒƒƒ|j|ƒ|jt|ƒtdƒƒtƒ}|jtdƒƒ|jt|ƒtttdƒƒƒƒ|jt|jt	ƒƒdS(NRHiRURVtabcddcbaiè(
RR%R@R*RRRRRR(RR((s+/usr/local/lib/python2.7/test/test_deque.pyttest_extendleft¶s
"
	(cCs2d}tt|ƒƒ}t|ƒ}xžt|ƒD]}|jƒ|jdƒtjƒdkr}|j|ƒ|j|ƒnxAtdt|ƒt|ƒƒD] }||||kst‚qWq1Wtdƒ}|j	|ddƒ|j	|ddƒtƒ}|j
t|jdƒ|j
t|jdƒdS(	NiÈigà?itsupermanRBiÿÿÿÿtn(
RRRRRtrandomRRtAssertionErrorRR%t
IndexErrort__getitem__(RR]RtlRtj((s+/usr/local/lib/python2.7/test/test_deque.pyttest_getitemÂs"


&"	cCsÓd}tt|ƒƒ}x"t|ƒD]}d|||<q%W|jt|ƒgt|ƒD]}d|^qYƒt|ƒ}x:td|ddƒD]"}d|||<d|||<q“W|jt|ƒ|ƒdS(NiÈi
iiiÿÿÿÿi(RRRR(RR]RRRb((s+/usr/local/lib/python2.7/test/test_deque.pyttest_setitemÖs3cCsäd}tt|ƒƒ}|jt|j|dƒ|jt|j|ƒx~t|ƒD]p}|jt|ƒ||ƒtjt|ƒt|ƒƒ}||}|j	||ƒ||=|j
||ƒqVW|jt|ƒdƒdS(Niôii(RRR%R`t__delitem__RRR^t	randrangetassertIntassertNotIn(RR]RRRctval((s+/usr/local/lib/python2.7/test/test_deque.pyttest_delitemâs
cCsÒd}gt|ƒD]}tjƒ^q}xŠt|ƒD]|}t|| ƒ}|jƒ}|jt|ƒtt|| ƒƒƒ|j|dƒ|jƒ|jt|ƒ|| ƒq8W|j	t
|jdƒdS(Niôi(RR^RRRRRtassertIsR0R%R@(RR]RtdataRtr((s+/usr/local/lib/python2.7/test/test_deque.pyttest_reverseðs%&
cCsûtdƒ}t|ƒ}t|ƒ}|jdƒ|jdj|ƒdƒt|ƒ}|jdƒ|jdj|ƒdƒ|jƒ|jt|ƒ|ƒxÈt|dƒD]¶}t|ƒ}t|ƒ}|j|ƒx!t|ƒD]}|jdƒqåW|jt|ƒt|ƒƒ|j|ƒ|jt|ƒ|ƒ|j||ƒ|jt|ƒ|ƒq­WxÈt|dƒD]¶}t|ƒ}t|ƒ}|j|ƒx!t|ƒD]}|jdƒq±W|jt|ƒt|ƒƒ|j|ƒ|jt|ƒ|ƒ|j||ƒ|jt|ƒ|ƒqxWt|ƒ}t|ƒ}|jtdƒ|j}xttdƒD]
}|ƒquW|jt|ƒt|ƒƒ|jt	|jd	ƒ|jt	|jdd
ƒtƒ}|jƒ|j|tƒƒdS(NtabcdeiR7teabcdiÿÿÿÿtbcdeaiiRRi
(
ttupleRRRARtjoinRtBIGR%R@(RRBR]RRRPRctdr((s+/usr/local/lib/python2.7/test/test_deque.pyttest_rotateüsX




		
cCsõtdƒ}|jt|ƒdƒ|jƒ|jt|ƒdƒ|jƒ|jt|ƒdƒ|jt|jƒ|jt|ƒdƒ|jdƒ|jt|ƒdƒ|jdƒ|jt|ƒdƒ|j	ƒ|jt|ƒdƒdS(NRGiiitcR(
RRRRRR%R`RRR(RR((s+/usr/local/lib/python2.7/test/test_deque.pyttest_len1s




cCs3tƒ}|jt|jƒ|jt|jƒdS(N(RR%R`RR(RR((s+/usr/local/lib/python2.7/test/test_deque.pyttest_underflowAs	cCs‚ttdƒƒ}|jt|ƒdƒ|jƒ|jt|ƒdƒ|jt|ƒgƒ|jƒ|jt|ƒgƒdS(Nidi(RRRRRR(RR((s+/usr/local/lib/python2.7/test/test_deque.pyt
test_clearFs

cCs]tdƒ}|jdƒ|j|tdƒƒ|jdƒ|j|tdƒƒ|jt|jdƒ|j|tdƒƒtddtƒdgƒ}t|ƒ}|jt|jdƒx0t||ƒD]\}}|j||kƒqËWxht	t
fD]Z}tdgƒ}|jt||ƒdgƒ|jt
|jdƒ|j|tƒƒqûWdS(NtabcdefghcijRxt
abdefghcijt	abdefghijRHRIRG(RtremoveRR%R&RRtzipt
assertTrueR>tFalseR)RR`(RRRPRRRStmatch((s+/usr/local/lib/python2.7/test/test_deque.pyttest_removeOs"

cCsgttdƒƒ}tt|ƒƒ}|jt|ƒt|ƒƒ|j|ƒ|jdt|ƒƒdS(NiÈs...(RRtevalR(RRRRh(RRRP((s+/usr/local/lib/python2.7/test/test_deque.pyt	test_reprgs

cCs©ttdƒƒ}|j|ƒtjtjƒttjdƒ}zF||I|jƒttjdƒ}|j|j	ƒt
|ƒƒWd|jƒtjtjƒXdS(NiÈR#R$(RRRRR+R,R-R.RR/R((RRR2((s+/usr/local/lib/python2.7/test/test_deque.pyt
test_printns


 
cCs0|jttdddƒ|jttdƒdS(NR!iii(R%R@R(R((s+/usr/local/lib/python2.7/test/test_deque.pyt	test_init|scCs|jtttdƒƒdS(NR!(R%R@thashR(R((s+/usr/local/lib/python2.7/test/test_deque.pyt	test_hash€scCs±xªdD]¢}tt|ƒƒ}|j|j}}xQt|tƒD]@}||ƒ|ƒ}|||krB|j|||ƒqBqBW|jt|ƒtt|tƒƒqWdS(Niiiidiè(iiiidiè(RRRRRuRRR(RtsizeRRRRRR((s+/usr/local/lib/python2.7/test/test_deque.pyt#test_long_steadystate_queue_popleftƒs

	cCsÃx¼dD]´}ttt|ƒƒƒ}|j|j}}xQt|tƒD]@}||ƒ|ƒ}|||krH|j|||ƒqHqHW|jttt|ƒƒƒtt|tƒƒqWdS(Niiiidiè(iiiidiè(	RRRRRRuRRR(RR‹RRRRRR((s+/usr/local/lib/python2.7/test/test_deque.pyt$test_long_steadystate_queue_poprightŽs

	cCs€tƒ}|j|j}}xttƒD]}||ƒq)Wx<ttƒD].}|ƒ}||krJ|j||ƒqJqJWdS(N(RRRRRuR(RRRRRRR((s+/usr/local/lib/python2.7/test/test_deque.pyttest_big_queue_popleft™s		cCs€tƒ}|j|j}}xttƒD]}||ƒq)Wx<ttƒD].}|ƒ}||krJ|j||ƒqJqJWdS(N(RRRRRuR(RRRRRRR((s+/usr/local/lib/python2.7/test/test_deque.pyttest_big_queue_popright¤s		cCsœtƒ}|j|j}}xttƒD]}||ƒq)WxBtttƒƒD].}|ƒ}||krP|j||ƒqPqPW|jt|ƒdƒdS(Ni(RRRRRuRRR(RRRRRRR((s+/usr/local/lib/python2.7/test/test_deque.pyttest_big_stack_right®s		cCsœtƒ}|j|j}}xttƒD]}||ƒq)WxBtttƒƒD].}|ƒ}||krP|j||ƒqPqPW|jt|ƒdƒdS(Ni(RRRRRuRRR(RRRRRRR((s+/usr/local/lib/python2.7/test/test_deque.pyttest_big_stack_left¹s		cCsZttdƒƒ}t|ƒ}|jt|ƒt|ƒƒ|jt|ƒt|ƒƒdS(NiÈ(RRtassertNotEqualtidRR(RRRP((s+/usr/local/lib/python2.7/test/test_deque.pyttest_roundtrip_iter_initÄscCsttdƒƒ}xtttjdƒD]_}tj||ƒ}tj|ƒ}|jt|ƒt|ƒƒ|j	t
|ƒt
|ƒƒq&WdS(NiÈi(RRRtpickletHIGHEST_PROTOCOLtdumpstloadsR’R“RR(RRRRBRP((s+/usr/local/lib/python2.7/test/test_deque.pyttest_pickleÊscCs‰dg}t|gƒ}tj|ƒ}|jt|ƒt|ƒƒd|d<|jt|ƒt|ƒƒ|jt|ƒt|ƒƒdS(Ni
ii(RtcopytdeepcopyRRR’R“(RtmutRRP((s+/usr/local/lib/python2.7/test/test_deque.pyt
test_deepcopyÚs	
cCs‰dg}t|gƒ}tj|ƒ}|jt|ƒt|ƒƒd|d<|jt|ƒt|ƒƒ|jt|ƒt|ƒƒdS(Ni
ii(RRšRRR’R“(RRœRRP((s+/usr/local/lib/python2.7/test/test_deque.pyt	test_copyãs	
cCsOxHdtdƒfD]4}|jttt|ƒƒƒtt|ƒƒƒqWdS(NRViÐ(RRRRR(RRB((s+/usr/local/lib/python2.7/test/test_deque.pyt
test_reversedìscCsGddl}tƒ}x+tdƒD]}|jdƒ|jƒq"WdS(Niÿÿÿÿidi(tgcRRRtcollect(RR RR((s+/usr/local/lib/python2.7/test/test_deque.pyttest_gc_doesnt_blowupðs
	
cCsºdtfd„ƒY}xtdƒD]}|ƒ}tj|ƒ}|dkrbt|dgƒ}ntt|dgƒƒ}t|ƒ|_~~tj	ƒ|j
|ƒdkdƒq#WdS(NtCcBseZRS((R
R(((s+/usr/local/lib/python2.7/test/test_deque.pyR£ûsiiisCycle was not collected(tobjectRtweakreftrefRRR'RRR R¡RR0(RR£RtobjR¦t	container((s+/usr/local/lib/python2.7/test/test_deque.pyttest_container_iteratorùs	
cCsåd}tjdƒ}tjd|ƒ}|jtjtƒƒ|ƒ|j}|tƒ||ƒ|tdƒ||ƒ|td|dƒ||ƒ|td|ddƒ|d|ƒ|tdd|ƒ|d|ƒdS(	Ni>t2P3PlPPs%dP2PRHiii*i+(	RtcalcobjsizetstructtcalcsizeRR¤t
__sizeof__Rtcheck_sizeof(RtBLOCKLENtbasesizet	blocksizetcheck((s+/usr/local/lib/python2.7/test/test_deque.pyttest_sizeofs	'()R
RR R3R4R6RERTRXRYR[RdReRkRoRwRyRzR{R„R†R‡RˆRŠRŒRRŽRRR‘R”R™RRžRŸR¢R©RR¯tcpython_onlyR´(((s+/usr/local/lib/python2.7/test/test_deque.pyRsJ		*		
	!									5													
													tTestVariousIteratorArgscBs#eZd„Zd„Zd„ZRS(cCsíxæddtdƒd	tdddƒfD]½}x`tjtjtjtjtjtjfD]4}|j	t
t||ƒƒƒt
||ƒƒƒqYW|jt
ttj|ƒƒ|jt
ttj|ƒƒ|jtttj|ƒƒq(WdS(
Nt123R7iètdog333333ó?iÐi˜i(R¸g333333ó?(RRRtSequencetIterFunctIterGentIterFuncStopt	itermultititerfuncRRRR%R@tIterNextOnlyt
IterNoNexttZeroDivisionErrort
IterGenExc(RRBtg((s+/usr/local/lib/python2.7/test/test_deque.pyttest_constructors.2cCs9tdƒ}t|ƒ}|jƒ|jt|jƒdS(Ntabcdefg(RR'RR%Rtnext(RRR1((s+/usr/local/lib/python2.7/test/test_deque.pyttest_iter_with_altered_data$s
cCs9tƒ}t|ƒ}|jdƒ|jt|jƒdS(Ni
(RR'RR%RRÆ(RRR1((s+/usr/local/lib/python2.7/test/test_deque.pyt!test_runtime_error_on_empty_deque*s	
(R
RRÄRÇRÈ(((s+/usr/local/lib/python2.7/test/test_deque.pyR¶s	
	tDequecBseZRS((R
R(((s+/usr/local/lib/python2.7/test/test_deque.pyRÉ0stDequeWithBadItercBseZd„ZRS(cCs
t‚dS(N(R@(R((s+/usr/local/lib/python2.7/test/test_deque.pyt__iter__4s(R
RRË(((s+/usr/local/lib/python2.7/test/test_deque.pyRÊ3stTestSubclasscBs>eZd„Zd„Zd„Zd„Zejd„ƒZRS(cCs–ttdƒƒ}|jtdƒƒx$tddƒD]}|j|ƒq5Wx*ttddƒƒD]}|j|ƒqbW|jt|ƒtddƒƒ|jt	|ƒdƒgtdƒD]}|j
ƒ^q»}|j|tddƒƒ|jt|ƒtddƒƒgtdƒD]}|jƒ^q}|jƒ|j|td	dƒƒ|jt|ƒtdd	ƒƒ|j
ƒ|jt	|ƒdƒdS(
NiiÈii8ÿÿÿiiXiúi2i–(RÉRRRRRRRRRRRRR(RRRRR((s+/usr/local/lib/python2.7/test/test_deque.pyR 9s"%%

cCsXtdƒ}|jƒ}|jt|ƒt|ƒƒ|jt|ƒt|ƒƒt|ƒ}|jt|ƒt|ƒƒ|jt|ƒt|ƒƒxttjdƒD]{}tj||ƒ}tj	|ƒ}|j
t|ƒt|ƒƒ|jt|ƒt|ƒƒ|jt|ƒt|ƒƒq¨Wtdddƒ}|jƒ}|jt|ƒt|ƒƒ|jt|ƒt|ƒƒt|ƒ}|jt|ƒt|ƒƒ|jt|ƒt|ƒƒxttjdƒD]{}tj||ƒ}tj	|ƒ}|j
t|ƒt|ƒƒ|jt|ƒt|ƒƒ|jt|ƒt|ƒƒqÕWdS(NR!iRpR"i(RÉt__copy__RRMRRR•R–R—R˜R’R“(RRRPtprotoRB((s+/usr/local/lib/python2.7/test/test_deque.pyttest_copy_pickleOs4 cCsTtdƒ}tj|ƒ}|jt|ƒt|ƒƒd}|jtt|ƒdS(Ntgallahad(RR¥tproxyRtstrR0R%tReferenceError(RRtp((s+/usr/local/lib/python2.7/test/test_deque.pyttest_weakref†s
cCsNdtfd„ƒY}|dddgƒ}|dddgƒ}||kdS(	NtXcBseZd„ZRS(cSs
tgƒS(N(R'(R((s+/usr/local/lib/python2.7/test/test_deque.pyRËs(R
RRË(((s+/usr/local/lib/python2.7/test/test_deque.pyRÖŽsiiiiii(R(RRÖtd1td2((s+/usr/local/lib/python2.7/test/test_deque.pyttest_strange_subclasssc
Cs€dtfd„ƒY}|ƒ}d„}||_|jtƒ
|dWdQX|jtƒ|tdddgƒWdQXdS(NRÖcBseZRS((R
R(((s+/usr/local/lib/python2.7/test/test_deque.pyRÖšsc_sdgS(Ni*((tclsRQtkwargs((s+/usr/local/lib/python2.7/test/test_deque.pytbad___new__si*iii(Rt__new__R%R@(RRÖRRÜ((s+/usr/local/lib/python2.7/test/test_deque.pyttest_bug_31608–s			(	R
RR RÏRÕRÙRRµRÞ(((s+/usr/local/lib/python2.7/test/test_deque.pyRÌ7s
		7			tSubclassWithKwargscBseZdd„ZRS(icCstj|ƒdS(N(RR(Rtnewarg((s+/usr/local/lib/python2.7/test/test_deque.pyR§s(R
RR(((s+/usr/local/lib/python2.7/test/test_deque.pyRߦstTestSubclassWithKwargscBseZd„Zd„ZRS(cCstddƒdS(NRài(Rß(R((s+/usr/local/lib/python2.7/test/test_deque.pyttest_subclass_with_kwargs«scCs|jdƒdS(Ns-Exhausted deque iterator doesn't free a deque(tskipTest(R((s+/usr/local/lib/python2.7/test/test_deque.pyttest_free_after_iterating¯s(R
RRâRä(((s+/usr/local/lib/python2.7/test/test_deque.pyRáªs	s‘

Example from the Library Reference:  Doc/lib/libcollections.tex

>>> from collections import deque
>>> d = deque('ghi')                 # make a new deque with three items
>>> for elem in d:                   # iterate over the deque's elements
...     print elem.upper()
G
H
I
>>> d.append('j')                    # add a new entry to the right side
>>> d.appendleft('f')                # add a new entry to the left side
>>> d                                # show the representation of the deque
deque(['f', 'g', 'h', 'i', 'j'])
>>> d.pop()                          # return and remove the rightmost item
'j'
>>> d.popleft()                      # return and remove the leftmost item
'f'
>>> list(d)                          # list the contents of the deque
['g', 'h', 'i']
>>> d[0]                             # peek at leftmost item
'g'
>>> d[-1]                            # peek at rightmost item
'i'
>>> list(reversed(d))                # list the contents of a deque in reverse
['i', 'h', 'g']
>>> 'h' in d                         # search the deque
True
>>> d.extend('jkl')                  # add multiple elements at once
>>> d
deque(['g', 'h', 'i', 'j', 'k', 'l'])
>>> d.rotate(1)                      # right rotation
>>> d
deque(['l', 'g', 'h', 'i', 'j', 'k'])
>>> d.rotate(-1)                     # left rotation
>>> d
deque(['g', 'h', 'i', 'j', 'k', 'l'])
>>> deque(reversed(d))               # make a new deque in reverse order
deque(['l', 'k', 'j', 'i', 'h', 'g'])
>>> d.clear()                        # empty the deque
>>> d.pop()                          # cannot pop from an empty deque
Traceback (most recent call last):
  File "<pyshell#6>", line 1, in -toplevel-
    d.pop()
IndexError: pop from an empty deque

>>> d.extendleft('abc')              # extendleft() reverses the input order
>>> d
deque(['c', 'b', 'a'])



>>> def delete_nth(d, n):
...     d.rotate(-n)
...     d.popleft()
...     d.rotate(n)
...
>>> d = deque('abcdef')
>>> delete_nth(d, 2)   # remove the entry at d[2]
>>> d
deque(['a', 'b', 'd', 'e', 'f'])



>>> def roundrobin(*iterables):
...     pending = deque(iter(i) for i in iterables)
...     while pending:
...         task = pending.popleft()
...         try:
...             yield task.next()
...         except StopIteration:
...             continue
...         pending.append(task)
...

>>> for value in roundrobin('abc', 'd', 'efgh'):
...     print value
...
a
d
e
b
f
c
g
h


>>> def maketree(iterable):
...     d = deque(iterable)
...     while len(d) > 1:
...         pair = [d.popleft(), d.popleft()]
...         d.append(pair)
...     return list(d)
...
>>> print maketree('abcdefgh')
[[[['a', 'b'], ['c', 'd']], [['e', 'f'], ['g', 'h']]]]

t
libreftestcCsÉddl}ttttf}tj|Œ|r¥t|dƒr¥ddl}dgd}xAt
t|ƒƒD]-}tj|Œ|jƒ|j
ƒ||<qlW|GHnddlm}tj||ƒdS(Niÿÿÿÿtgettotalrefcounti(t
test_deque(tsysRR¶RÌRáRtrun_unittestthasattrR R0RRR¡RættestRçtrun_doctest(tverboseRèttest_classesR tcountsRRç((s+/usr/local/lib/python2.7/test/test_deque.pyt	test_mains 	



t__main__Rí(tcollectionsRtunittestRëRRR R¥RštcPickleR•R^R¬RuRRRtTestCaseRR¶RÉRÊRÌRßRáRåt__test__R0RðR
R>(((s+/usr/local/lib/python2.7/test/test_deque.pyt<module>s2	ÿüom


Zerion Mini Shell 1.0