diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-02-10 20:54:27 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-02-10 20:54:27 (GMT) |
commit | 95b8614353eee05f350c794a0aa37cab39794eed (patch) | |
tree | 3c2164e8f194f6ca46d70cb0f29d17aeeebd90ba /Lib | |
parent | 41d84631ba53a484e79c4e1d4f0a968a986d8945 (diff) | |
download | cpython-95b8614353eee05f350c794a0aa37cab39794eed.zip cpython-95b8614353eee05f350c794a0aa37cab39794eed.tar.gz cpython-95b8614353eee05f350c794a0aa37cab39794eed.tar.bz2 |
add an __len__ to Set and Stack
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/compiler/misc.py | 4 |
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): |