diff roundup/anypy/sets_.py @ 4089:eddb82d0964c

Add compatibility package to allow us to deal with Python versions 2.3..2.6. Outstanding issues noted in roundup/anypy/TODO.txt
author Richard Jones <richard@users.sourceforge.net>
date Thu, 12 Mar 2009 02:52:56 +0000
parents
children 06af6d5bedbe
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/roundup/anypy/sets_.py	Thu Mar 12 02:52:56 2009 +0000
@@ -0,0 +1,30 @@
+"""
+anypy.sets_: sets compatibility module
+
+uses the built-in type 'set' if available, and thus avoids
+deprecation warnings. Simple usage:
+
+Change all
+    from sets import Set
+to
+    from roundup.anypy.sets_ import set
+
+and use 'set' instead of 'Set'.
+To avoid unnecessary imports, you can:
+
+    try:
+        set
+    except NameError:
+        from roundup.anypy.sets_ import set
+
+see:
+http://docs.python.org/library/sets.html#comparison-to-the-built-in-set-types
+
+"""
+
+try:
+    set = set                     # built-in since Python 2.4
+except NameError, TypeError:
+    from sets import Set as set   # deprecated as of Python 2.6
+
+# vim: ts=8 sts=4 sw=4 si et

Roundup Issue Tracker: http://roundup-tracker.org/