how to use a variable as an object property in python

Discussion created by lukestudden on May 5, 2011
Latest reply on May 5, 2011 by lpugh01
Hi all,

I am using python (9.3) to automate the creation of numerous Featureclasses. Along the way I am adding a new column (field) to each which the field name is essentially a variable as it is all data driven. I am then using the UpdateCursor to update the value of the field with the value of another within the same Feature class. The problem is that since the field name I have added is a variable, I can not use the update cursor to refer to it as it changes after each loop iteration. Is there any way you can use a variable as an objects property, eg.

instead of explicitly stating the field to be updated eg. updaterow1.car1 I would like to use a variable eg: updaterow1.carnumber

Carnumber would then change after each iteration eg. car1, car2, car3 etc.

Is this possible?