On May 25, 4:43 pm, "Michal Lipinski" <[EMAIL PROTECTED]> wrote: > now it's working just fine. but still I dont know why eval dont work ? > > and thx for help > > 25 May 2007 15:05:03 -0700, 7stud <[EMAIL PROTECTED]>: > > > > > Here's a complete example: > > > ################### > > #create object 's': > > > class S(object):pass > > class X(object):pass > > class Y(object):pass > > > s = S() > > s.components = X() > > s.components.d1 = Y() > > s.components.d2 = Y() > > s.components.d3 = Y() > > ###################### > > > ###################### > > set some initial values: > > for i in range(1, 4): > > obj = getattr(s.components, "d" + str(i)) > > obj.text = "hello world" > > ##################### > > > ##################### > > #change the values: > > for i in range(1, 4): > > getattr(s.components, "d" + str(i)).text = "goodybe" > > ##################### > > > ##################### > > #print out the new values: > > for i in range(1, 4): > > print getattr(s.components, "d" + str(i)).text > > ##################### > > > -- > >http://mail.python.org/mailman/listinfo/python-list > > -- > Pozdrawiam > > Micha³ Lipiñski > > http://lipton.kom.pl
1) Don't use eval() 2) Don't use eval() 3) eval() only works on python "expressions". In python, an assignment statement is not an expression.
-- http://mail.python.org/mailman/listinfo/python-list