Create the text representation of a bit string by means of the builtin
.format() method and an appropriate specifier. Drop the non-obvious
sequence of bin() and slice and zfill() calls.
else:
self.tmp |= (bit << (c - 1))
if c == 14:
- s = bin(self.tmp)[2:].zfill(14)
+ s = '{:014b}'.format(self.tmp)
self.putb([1, ['Special bits: %s' % s, 'SB: %s' % s]])
elif c == 15:
s = '' if (bit == 1) else 'not '
# Most (but not all) states need this.
if self.state != 'IDLE':
lad = (lad3 << 3) | (lad2 << 2) | (lad1 << 1) | lad0
- lad_bits = bin(lad)[2:].zfill(4)
+ lad_bits = '{:04b}'.format(lad)
# self.putb([0, ['LAD: %s' % lad_bits]])
# TODO: Only memory read/write is currently supported/tested.