forked from adafruit/circuitpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeque_subclass.py
More file actions
40 lines (31 loc) · 823 Bytes
/
Copy pathdeque_subclass.py
File metadata and controls
40 lines (31 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
try:
from collections import deque
except ImportError:
print("SKIP")
raise SystemExit
class DequeSubclass(deque):
def __init__(self, values, maxlen):
super().__init__(values, maxlen)
def pop(self):
print("pop")
return super().pop()
def popleft(self):
print("popleft")
return super().popleft()
def append(self, value):
print("append")
return super().append(value)
def appendleft(self, value):
print("appendleft")
return super().appendleft(value)
def extend(self, value):
print("extend")
return super().extend(value)
d = DequeSubclass([1, 2, 3], 10)
print(d.append(4))
print(d.appendleft(0))
print(d.pop())
print(d.popleft())
d.extend([6, 7])
# calling list() tests iteration.
print(list(d))