summaryrefslogtreecommitdiffstats
path: root/Lib/compiler/misc.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2000-02-10 20:54:27 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2000-02-10 20:54:27 (GMT)
commit95b8614353eee05f350c794a0aa37cab39794eed (patch)
tree3c2164e8f194f6ca46d70cb0f29d17aeeebd90ba /Lib/compiler/misc.py
parent41d84631ba53a484e79c4e1d4f0a968a986d8945 (diff)
downloadcpython-95b8614353eee05f350c794a0aa37cab39794eed.zip
cpython-95b8614353eee05f350c794a0aa37cab39794eed.tar.gz
cpython-95b8614353eee05f350c794a0aa37cab39794eed.tar.bz2
add an __len__ to Set and Stack
Diffstat (limited to 'Lib/compiler/misc.py')
-rw-r--r--Lib/compiler/misc.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/compiler/misc.py b/Lib/compiler/misc.py
index 0dc6422..a281c10 100644
--- a/Lib/compiler/misc.py
+++ b/Lib/compiler/misc.py
@@ -1,6 +1,8 @@
class Set:
def __init__(self):
self.elts = {}
+ def __len__(self):
+ return len(self.elts)
def add(self, elt):
self.elts[elt] = elt
def items(self):
@@ -14,6 +16,8 @@ class Stack:
def __init__(self):
self.stack = []
self.pop = self.stack.pop
+ def __len__(self):
+ return len(self.stack)
def push(self, elt):
self.stack.append(elt)
def top(self):