Python metaclasses: how do I generalize this helper class? -


i using pytables store python data in hdf5 file, , requires helper class create table. here example:

class packetdata(pt.isdescription):     data = pt.uint8col(shape=(128,))   # later code this: self.tdata = self.hfile.createtable(self.g, 'packetdata', packetdata,                             filters=filters) 

is there way generalize 128 here using metaclass?

i don't think need metaclass here. in fact, since metaclass fixed @ point class defined, don't think provides opportunity parametrize shape.

you use class factory instead:

def packetdata(n):     class packetdata(pt.isdescription):         data = pt.uint8col(shape=(n,))     return packetdata  self.tdata = self.hfile.createtable(self.g, 'packetdata', packetdata(128),                             filters=filters) 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -