Index: spacemap.py ================================================================== --- spacemap.py +++ spacemap.py @@ -1,6 +1,6 @@ -class SpaceMap: +class SpaceMap(object): ''' Here we have: __bottom - minimum space address possible; __top - maximum space address possible; __pairs - internal list of ranges; __walk_list - internal list of keys.''' @@ -27,14 +27,14 @@ def __set(self, name, value): '''Internal function to add ranges without folding. Also checks for range correctness.''' if type(name) != int or type(value) != int or name >= value: return(False) - if not self.__bottom == None: + if self.__bottom != None: if name < self.__bottom or value < self.__bottom: return(False) - if not self.__top == None: + if self.__top != None: if name >= self.__top or value >= self.__top: return(False) self.__pairs[name] = value return True @@ -82,11 +82,11 @@ '''Returns the inner dict with ranges.''' return(repr(self.__pairs)) def __and__(self, other): '''Returns new space map with ranges that appears both in A and B.''' - if not type(other) == SpaceMap: + if type(other) != SpaceMap: return(False) new = {} self.rewind() other.rewind() my_pair = self.pop() @@ -179,11 +179,11 @@ other.clear() return(SpaceMap(new, self.__bottom, self.__top)) def __sub__(self, other): '''Returns new space map with ranges in A not covered by B.''' - if not type(other) == SpaceMap: + if type(other) != SpaceMap: return(False) new = {} self.rewind() other.rewind() my_pair = self.pop() Index: test.py ================================================================== --- test.py +++ test.py @@ -1,5 +1,9 @@ +from __future__ import print_function, unicode_literals + +from spacemap import SpaceMap + def test(): def check(desc, correct, result): if correct == result: print('PASSED:', desc, '==' , result, '==', correct) else: