How to create a method that can make class variables in python? -


let's want make object has method adds variables function. example lets have object called obj. when write obj.create_var("sample_variable"), can call obj.sample_variable. want method takes name of variable parameter , creates variable on object. how write method?

def createvar(self, name, value):     setattr(classname, name, value) 

Comments

Popular posts from this blog

android - questions about switching from C2DM to GCM -

c++ - rosrun via ssh doesnt start a node properly -

Error C2280 mutex in a class C++ -