2008/9/4 Chris Rebert <[EMAIL PROTECTED]>: > On Thu, Sep 4, 2008 at 12:25 AM, Mathieu Prevot > <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I have a program that take a word as argument, and I would like to >> link this word to a class variable. >> >> eg. >> class foo(): > > You should subclass 'object', so that should be: > class Foo(object): > >> width = 10 >> height = 20 >> >> a=foo() >> arg='height' >> a.__argname__= new_value > > You're looking for the setattr() built-in function. In this exact case: > setattr(a, arg, new_value) > > This is probably covered in the Python tutorial, please read it. > > Regards, > Chris
Indeed. I'll use: a.__setattr__(height, new_value) Thanks to all Mathieu -- http://mail.python.org/mailman/listinfo/python-list