More user feedback on Sets.py

David Eppstein eppstein at ics.uci.edu
Sun Nov 9 14:13:51 EST 2003


In article <Rxlrb.6067$hB5.3380 at nwrdny02.gnilink.net>,
 "Raymond Hettinger" <vze4rx4y at verizon.net> wrote:

> I have added some backwards compatability code so that Sets.py will run
> Python 2.2.  Please give it a test drive:
> 
> http://cvs.sourceforge.net/viewcvs.py/*checkout*/python/python/dist/src/Lib/se
> ts.py?content-type=text%2Fplain&rev=1.44.8.4

Thanks!  Doesn't quite work out of the box, though...

Python 2.2 (#1, 07/14/02, 23:25:09) 
[GCC Apple cpp-precomp 6.14] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sets
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.2/site-packages/sets.py", line 79, in ?
    class BaseSet(object):
  File "/usr/lib/python2.2/site-packages/sets.py", line 109, in BaseSet
    def _repr(self, sorted=False):
NameError: name 'False' is not defined
>>> 

Here's a patch:

*** sets.py     Sun Nov  9 09:48:47 2003
--- /usr/lib/python2.2/site-packages/sets.py    Sun Nov  9 11:09:35 2003
***************
*** 74,79 ****
--- 74,83 ----
              if not predicate(x):
                  yield x
  
+ if 'True' not in globals():
+     globals()['True'] = not None
+     globals()['False'] = not True
+ 
  __all__ = ['BaseSet', 'Set', 'ImmutableSet']
  
  class BaseSet(object):

-- 
David Eppstein                      http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science




More information about the Python-list mailing list