Chris <cf*****@bigpond.net.auwrote:
>I have a instance attribute self.xds and a local variable xds in the
instance . Both are dictionaries. I understand that I can update
self.xds with xds as follows: self.xds.update(xds)
However I have many instance attributes, self.i, and local variables i.
I'd like to be able to do this:
for i in list_of_i's:
self.i.update(i)
How can this be done (I'm assuming it can be).
I think what you want is:
for i in list_of_is:
getattr(self, i).update(locals()[i])
assuming list_of_is is a list of names not a list of the local
dicts (ie ["xds", ...] not [xds, ...]).
--
\S --
si***@chiark.greenend.org.uk --
http://www.chaos.org.uk/~sion/
___ | "Frankly I have no feelings towards penguins one way or the other"
\X/ | -- Arthur C. Clarke
her nu becomež se bera eadward ofdun hlęddre heafdes bęce bump bump bump