so.. to put this simply:
>>> BU5 = bu(5)
>>> BU5()
0
>>> BU5(1024)
1024
>>> BU5 == bu(5)
False
>>> BU5
<__main__.bu instance at 0x00AC5E40>
>>> bu(5)
<__main__.bu instance at 0x012C6788>
BU5 == bu(5) is supposed to return True due to it's expected usage:
>>> var = bu(5)() #read big u-int from 5 bytes
>>> type(var) == bu(5)
True
I was thinking to use a dictionary and reference the first class initializer based on the byte-size
but how would I compair it properly??
here's the current code for my class:
_buTypes = {}
class bu:
def __init__(self,byte_size):
self.size = byte_size
self.value = 0
try: _buTypes[byte_size]
except KeyError: _buTypes[byte_size] = self
def __call__(self,value=''):
self.value = 0 if value=='' else value #_BIT(self.size,big,bit_format,value,label='')
return self.value
can anyone help?? :/