blob: 8c638a934c5215deec93b9bfd2f87511cd4abf3e (
about) (
plain)
1
2
3
4
5
6
7
8
|
class HexFormattingMixin(object):
def __str__(self):
n = int(self)
width = (self.width + 3) // 4
if n < 0:
return '-0x%0*x' % (width, -n)
else:
return '0x%0*x' % (width, n)
|