Dynamically reference member of array
bmcollier at gmail.com
Wed Mar 26 12:43:49 CET 2014
I know that I can dynamically reference a variable with locals()["i"], for instance, but I'd like to know how to do this with a variable in an object.
If I have an object called "device", with variables called attr1, attr2 .. attr50, how could I dynamically reference these?
It's fairly academic, but I'd like to avoid code duplication.
More information about the Python-list