I have 12 classes that look like this, the only difference is DefaultAsset
global object. I have 12 of those global DefaultAssetOrderedDict
, such as DefaultAssetsOrderedDict
, NewAssetsOrderedDict
, OldAssetsOrderedDict
, etc. I didn't make them part of each class because they are large and I suspect doing so would result in multiple instances of something that is intended to be static, correct me if I'm wrong (I've had a lot of memory issues, switching from OrderDict data rows to class data rows to fix it)
class DefaultAsset(object):
__slots__ = list(DefaultAssetOrderedDict.keys())
def __init__(self, **kwargs):
for arg, default in DefaultAssetOrderedDict.items():
setattr(self, arg, re.sub(r'[^\x00-\x7F]', '', kwargs.get(arg, default)))
#print (str(arg) + " : "+ str(re.sub(r'[^\x00-\x7F]', '', kwargs.get(arg, default))))
def items(self):
for slot in self.__slots__:
yield slot, getattr(self, slot)
def values(self):
for slot in self.__slots__:
yield getattr(self, slot)
So, I want to know how I can re-write that above class so that it's a parent class called Rows
and so that I can do something like this:
class DefaultAssets (Row, DefaultAssetOrderedDict):
#does the same thing but per the OrderedDict in second argument
or maybe:
DefaultAssets = Rows(DefaultAssetOrderedDict)
NewAssets = Rows(NewAssetOrderedDict)