Made catch return and fixed __repr__ of queue.

This commit is contained in:
Jeremy Fincher 2003-04-03 06:57:01 +00:00
parent a5fc83ef63
commit f682f639c5

View File

@ -44,7 +44,7 @@ def ignore(*args, **kwargs):
def catch(f, *args, **kwargs): def catch(f, *args, **kwargs):
try: try:
f(*args, **kwargs) return f(*args, **kwargs)
except: except:
pass pass
@ -175,7 +175,7 @@ class queue(dict):
return False return False
def __repr__(self): def __repr__(self):
return 'queue(%s)' % ', '.join(map(str, self)) return 'queue(%s)' % ', '.join(map(repr, self.itervalues()))
class IterableMap(object): class IterableMap(object):
@ -249,6 +249,8 @@ def enumerate(L):
yield (i, L[i]) yield (i, L[i])
def window(L, size): def window(L, size):
if size <= 0:
raise ValueError, 'sizes <= 0 unallowed.'
for i in xrange(len(L) - (size-1)): for i in xrange(len(L) - (size-1)):
yield L[i:i+size] yield L[i:i+size]