Deborah Swanson wrote:
I've run into this kind of problem with namedtuples before, trying to
access field values with variable names, like:
label = 'Location'
records.label
If you need to access an attribute whose name is computed
at run time, you want getattr() and setattr():
value = getattr(record, label)
setattr(record, label, value)
Using these, I suspect you'll be able to eliminate all
the stuff you've got that messes around with indexes to
access field values, making the code a lot simpler and
easier to follow.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list