tags:

views:

67

answers:

1

Hello,

With Python it is easy to declare something like

self.x = "something"
print self.x #outputs "something"

I want to have something like this:

param["key"] = "x"
self.param["key"] = "something" #here I actually want to access this "self" parameter as below with its value defined above
print self.x #supposed to output "something" as well. Note that "x" refers to value defined in the first line

Is there any such thing? Is there any similar alternatives?

Thanks in advance.

+4  A: 

Use setattr -- setattr(self, param['key'], 'something').

PiotrLegnica
thank you very much
celalo