mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Improvements to collections.deque():
* Add doctests for the examples in the library reference. * Add two methods, left() and right(), modeled after deques in C++ STL. * Apply the new method to asynchat.py. * Add comparison operators to make deques more substitutable for lists. * Replace the LookupErrors with IndexErrors to more closely match lists.
This commit is contained in:
parent
fe99927630
commit
738ec90ca1
4 changed files with 229 additions and 18 deletions
|
@ -262,11 +262,7 @@ class fifo:
|
|||
return self.list == []
|
||||
|
||||
def first (self):
|
||||
it = iter(self.list)
|
||||
try:
|
||||
return it.next()
|
||||
except StopIteration:
|
||||
raise IndexError
|
||||
return self.list.left()
|
||||
|
||||
def push (self, data):
|
||||
self.list.append(data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue