setattr for secondary attribute
Alex
OurLab at gmail.com
Sun Nov 20 23:34:39 EST 2005
More information about the Python-list mailing list
Sun Nov 20 23:34:39 EST 2005
- Previous message (by thread): Aproximative string matching
- Next message (by thread): setattr for secondary attribute
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I apologize for asking maybe a very trivial question. I have a new class object A with slots. One of the slots is, for example, object spam. Object spam, in turn, also has slots and one of them is attribute eggs. I need to assign a new value to eggs. In other words, I need to perform the following: A.spam.eggs=newValue The problem is that I have only a string s='spam.eggs' with which to work, so I cannot write an expression written above. I tried to use setattr: setattr(A, s, newValue) but this does not work. It says that object A does not have attribute spam.eggs How would you do it? TIA.
- Previous message (by thread): Aproximative string matching
- Next message (by thread): setattr for secondary attribute
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list