Hello!

Is there a better way of doing this?
Why didn't setattr (as commented) work?

Thanks for an help/comments.

class C:
    def f(self,v):
        #setattr(self,n,v)
        self.__dict__['n']=v

c=C()
c.f(3)
print(c.n)

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to