forked from Imagelibrary/seL4
python: add __str__() for Region
- Provide a nicer string for debugging purposes. - improve comments about the purpose of __repr__() and __str__() Signed-off-by: Axel Heider <axelheider@gmx.de>
This commit is contained in:
@@ -24,8 +24,17 @@ class Region:
|
||||
return ret
|
||||
|
||||
def __repr__(self):
|
||||
''' Returns a string representation that is a valid Python expression
|
||||
that eval() can parse. '''
|
||||
return 'Region(base=0x{:x},size=0x{:x})'.format(self.base, self.size)
|
||||
|
||||
def __str__(self):
|
||||
''' Returns a string representation. '''
|
||||
return 'Region [0x{:x}..0x{:x}] ({:d} bytes)'.format(
|
||||
self.base,
|
||||
self.base + self.size - (1 if self.size > 0 else 0),
|
||||
self.size)
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.base == other.base and self.size == other.size
|
||||
|
||||
|
||||
Reference in New Issue
Block a user