Normally you use setattr() if the name of the attribute is in a
namestring:
setattr(self, namestring, value)
But my attributes are lists or dictionaries, and I don't seem to be
able to use setattr anymore.
Now I use for a list something like:
self.__dict__[namestring].append(value)
and for a
On Thu, Jul 1, 2010 at 3:56 AM, egbert egber...@xs4all.nl wrote:
Normally you use setattr() if the name of the attribute is in a
namestring:
setattr(self, namestring, value)
But my attributes are lists or dictionaries, and I don't seem to be
able to use setattr anymore.
Because you're not
On 07/01/10 20:56, egbert wrote:
self.__dict__[namestring][keystring]=value
try this:
getattr(self, namestring)[keystring] = value
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Jul 01, 2010 at 04:02:49AM -0700, Chris Rebert wrote:
switch to getattr() as demonstrated above.
Thanks for opening my eyes, Chris.
egbert
--
Egbert Bouwman - Keizersgracht 197 II - 1016 DS Amsterdam - 020 6257991
egbert a écrit :
Normally you use setattr() if the name of the attribute is in a
namestring:
setattr(self, namestring, value)
But my attributes are lists or dictionaries, and I don't seem to be
able to use setattr anymore.
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on
On Thu, Jul 01, 2010 at 02:28:37PM +0200, Bruno Desthuilliers wrote:
Either I failed to understand you or you overlooked some other
problem in you code and jumped to the wrong conclusions.
In my problem the the name of the list or dict to mutate arrives in namestring,
so I could not use the