what I'm basically trying to do is:
x = struct( size=4, order='var0', # <<< struct.__call__( size, order, **vars )
var0 = bu32 # { 'var0': bu32, }
)
data = x() # read data from imported file
print data.var0 # should return a bu32 int
if data.__class__ == x: pass
# these next 2 should reference the same object
if data.__class__.__class__ == struct: pass
if x.__class__ == struct: pass
I believe it's possible, but I'm not sure how to do it...
so what does everything in the code above do exactly?
bu32() is a data function which reads a big-endian unsigned 32bit int or 0x00000000 from a file imported into my interface.
struct() is an advanced class which when called calls those functions in the order given to read the data from the file AND structure the data as the vars given.
x = struct()
x is a new sub-class returned by struct used for identifying particular data structures in your code.
as you can guess, sub-classing is something new to me, so I have no idea how to do this.
another way to represent this: (for those confused who might have an idea)
here's what's expected:
>>> type(x)
<class '__main__.struct'>
>>> data = x()
>>> type(data) # name changed
<class '__main__.x'>
thanks for any and all help :)
EDIT: I should mention I'm using portable python which is no later than version 2.7.6.1