Namedtuples: some unexpected inconveniences

Peter Otten __peter__ at web.de
Thu Apr 13 02:34:55 EDT 2017


Deborah Swanson wrote:

> It's a small point, but I suspect getattr(record, label) would still
> fail, even if label's value is 'label' and only 'label', but what's the
> point of having a variable if it will only ever have just one value?

You are misunderstanding. Your getattr() call fails because you have

label = "label"

burried somewhere in your code. As soon as you change that to

label = <insert an existing attribute name here>

the error will go away. 




More information about the Python-list mailing list