I have a named tuple object defined with 63 different items in it. I use the _make function. I think this approach will work but need 4x63 more rows for the try except statements. There has to be a better way:
AssetRow = collections.namedtuple('AssetRow', [
"status",
"computer_name",
.
.
.
61 more
def create_asset_row(Object):
try:
Object.status
except
Object.status = ""
try:
Object.computer_name
except
Object.computer_name= ""
values = [
Object.status,
Object.computer_name,
.
.
.
61 more
]
row = AssetRow._make(values)
basically I want to make sure the named tuple is set to "" if I don't have a value to put in it.... but I don't want to write 500 lines to do it... I want to write about 67 lines