[Python-checkins] python/dist/src/Lib sets.py,1.44,1.44.8.1

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Fri Aug 15 15:14:54 EDT 2003


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv9535/Lib

Modified Files:
      Tag: release23-maint
	sets.py 
Log Message:
Make sets.py compatible with Py2.2

Index: sets.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sets.py,v
retrieving revision 1.44
retrieving revision 1.44.8.1
diff -C2 -d -r1.44 -r1.44.8.1
*** sets.py	26 Jun 2003 18:49:28 -0000	1.44
--- sets.py	15 Aug 2003 21:14:51 -0000	1.44.8.1
***************
*** 55,61 ****
  #   improvements.
  
  
  __all__ = ['BaseSet', 'Set', 'ImmutableSet']
- from itertools import ifilter, ifilterfalse
  
  class BaseSet(object):
--- 55,79 ----
  #   improvements.
  
+ from __future__ import generators
+ try:
+     from itertools import ifilter, ifilterfalse
+ except ImportError:
+     # Code to make the module run under Py2.2
+     def ifilter(predicate, iterable):
+         if predicate is None:
+             def predicate(x):
+                 return x
+         for x in iterable:
+             if predicate(x):
+                 yield x
+     def ifilterfalse(predicate, iterable):
+         if predicate is None:
+             def predicate(x):
+                 return x
+         for x in iterable:
+             if not predicate(x):
+                 yield x
  
  __all__ = ['BaseSet', 'Set', 'ImmutableSet']
  
  class BaseSet(object):





More information about the Python-checkins mailing list