I have various html tables that I need to parse/access from my customers web-page, the data on it might vary across the tables (length of columns).
So, what I've done was to create a class for each table but this task became ridiculous, since there are a lot of tables that I need to parse with data varying.
Is there any way to implement DTOs in python other than creating a class for each data that I what to transfer?
class HoldItem():
@property
def none1(self):
return self
@property
def none2(self):
return self
@property
def item(self):
return self
@property
def plant(self):
return self
@property
def location(self):
return self
@property
def material(self):
return self
@none1.setter
def none1(self, value):
self.none1 = value
items = []
for tds in trs:
item = HoldItem()
if (x == PROP_A):
item.prop_a = tds.InnerText
...
...
...
items.append(item)
return items
for item in items:
command.AddWithValue("@prop_a", item.prop_a)
The Messenger
object seems to make sense for your purpose. It is designed as a way to pass data around.
Python is dynamic.
Override __get__
and __set__
and store 'field values' in a dictionary internal to your class (instance).