00001 """Compatibility stuff""" 00002 00003 # begin[licence] 00004 # 00005 # [The "BSD licence"] 00006 # Copyright (c) 2005-2008 Terence Parr 00007 # All rights reserved. 00008 # 00009 # Redistribution and use in source and binary forms, with or without 00010 # modification, are permitted provided that the following conditions 00011 # are met: 00012 # 1. Redistributions of source code must retain the above copyright 00013 # notice, this list of conditions and the following disclaimer. 00014 # 2. Redistributions in binary form must reproduce the above copyright 00015 # notice, this list of conditions and the following disclaimer in the 00016 # documentation and/or other materials provided with the distribution. 00017 # 3. The name of the author may not be used to endorse or promote products 00018 # derived from this software without specific prior written permission. 00019 # 00020 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00021 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00022 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00023 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 00024 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00025 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00026 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00027 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00028 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00029 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 # 00031 # end[licence] 00032 00033 try: 00034 set = set 00035 frozenset = frozenset 00036 except NameError: 00037 from sets import Set as set, ImmutableSet as frozenset 00038 00039 00040 try: 00041 reversed = reversed 00042 except NameError: 00043 def reversed(l): 00044 l = l[:] 00045 l.reverse() 00046 return l 00047 00048