[Python-checkins] python/dist/src/Doc/lib libcollections.tex, 1.6,
1.7
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Fri Apr 30 18:52:54 EDT 2004
Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28472
Modified Files:
libcollections.tex
Log Message:
Add an example application to the docs.
Index: libcollections.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcollections.tex,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** libcollections.tex 1 Mar 2004 23:16:21 -0000 1.6
--- libcollections.tex 30 Apr 2004 22:52:50 -0000 1.7
***************
*** 68,72 ****
Rotate the deque \var{n} steps to the right. If \var{n} is
negative, rotate to the left. Rotating one step to the right
! is equivalent to: \samp{d.appendleft(d.pop())}.
\end{methoddesc}
--- 68,72 ----
Rotate the deque \var{n} steps to the right. If \var{n} is
negative, rotate to the left. Rotating one step to the right
! is equivalent to: \samp{d.appendleft(d.pop())}.
\end{methoddesc}
***************
*** 129,132 ****
>>> d
deque(['c', 'b', 'a'])
! \end{verbatim}
--- 129,161 ----
>>> d
deque(['c', 'b', 'a'])
+ \end{verbatim}
!
! A roundrobin task server can be built from a \class{deque} using
! \method{popleft()} to select the current task and \method{append()}
! to add it back to the tasklist if the input stream is not exhausted:
!
! \begin{verbatim}
! 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
!
! \end{verbatim}
More information about the Python-checkins
mailing list