problem with eval while using PythonCard

Michal Lipinski michal.lipinski at gmail.com
Fri May 25 17:33:15 EDT 2007


Hi

its my first post. I have a problem, I want to user eval() function in
a for loop to  set labels to staticText so i done something like this:

  dzien=self.components.Calendar.GetDate().GetDay()
   for i in range(1,8):
            act=dzien+i -1
            eval( 'self.components.d' + str(i) + '.text = "'+ str(act) + '"')

but there is a problem, the program returned error:

  File "/home/lipton/Projekty/kami-organizer/grafik.py", line 27, in __init__
    eval( 'self.components.d' + str(i) + '.text = "'+ str(act) + '"')
  File "<string>", line 1
    self.components.d1.text = "25"

SyntaxError: invalid syntax

dont know what is wrong, becouse when i copy and paste in to code :
  self.components.d1.text = "25"

it work great, but when Im trying to do it using eval() it give me a SyntaxError

Please help.

ps. sorry for my english ;)



More information about the Python-list mailing list