Understood - and thanks for your quick response. Overall this is a fantastic module, and has proved very useful for me.
I only raise this because any deviation from python "norms" is a bug waiting to happen (fortunately it caused an exception later in my code, so I was able to catch it)
To give a quick example:
for addr in range(0, EEPROM_SIZE, BLOCK_SIZE): eeprom.i2c_write(addr, ih.tobinarray(addr, addr + BLOCK_SIZE - 1))
The "-1" is messy, and shouldn't be required (and looks a lot like visual basic!).
Another alternative is to create a wrapper function with "pythonic" behaviour and deprecate the old function, so existing code is not broken but new code is more intuitive.
def to_binary_array(self, start=None, end=None, pad=None):
if end is not None:
end = end - 1
self.tobinarray(start, end, pad)
Understood - and thanks for your quick response. Overall this is a fantastic module, and has proved very useful for me.
I only raise this because any deviation from python "norms" is a bug waiting to happen (fortunately it caused an exception later in my code, so I was able to catch it)
To give a quick example:
eeprom. i2c_write( addr, ih.tobinarray(addr, addr + BLOCK_SIZE - 1))
for addr in range(0, EEPROM_SIZE, BLOCK_SIZE):
The "-1" is messy, and shouldn't be required (and looks a lot like visual basic!).
Another alternative is to create a wrapper function with "pythonic" behaviour and deprecate the old function, so existing code is not broken but new code is more intuitive.
def to_binary_ array(self, start=None, end=None, pad=None): tobinarray( start, end, pad)
if end is not None:
end = end - 1
self.