From 1dc82ec02cb87b624b0528bde290f7462bebf593 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 3 Apr 2003 08:17:57 +0000 Subject: [PATCH] Made set more in line with the sets that will be released in 2.3 --- src/fix.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/fix.py b/src/fix.py index 144423ffe..6a7f46326 100644 --- a/src/fix.py +++ b/src/fix.py @@ -124,8 +124,13 @@ class set(object): self.d[x] = None def remove(self, x): - if x in self.d: + del self.d[x] + + def discard(self, x): + try: del self.d[x] + except KeyError: + pass class queue(dict): @@ -249,8 +254,8 @@ def enumerate(L): yield (i, L[i]) def window(L, size): - if size <= 0: - raise ValueError, 'sizes <= 0 unallowed.' + if size < 1: + raise ValueError, 'size <= 0 unallowed.' for i in xrange(len(L) - (size-1)): yield L[i:i+size]