From: Ed L. <ed...@le...> - 2006-12-18 13:21:28
|
On Dec 18, 2006, at 8:13 AM, Alec Bennett wrote: > For example, instead of saying something like: > > self.components.button4.file = "some_picture.jpg" > > I'd like to be able to do something like: > > button_number = 4 > button = 'self.components.button" + `button_number` + ".file = > "some_picture.jpg"' > > Currently I'm burying everything in way too many if statements, which > is always a sign I'm doing things sloppily. If I could write a > function that, for example, redraws only a specific button, my code > would get much neater. But without being able to script or concatenate > the component name, I can't think of a way to do that. > > Is such a thing possible? Or is there some clever way to achieve > the same thing? You could do this with Python's exec statement. Construct the text of the command, and then use exec to execute it. -- Ed Leafe -- http://leafe.com -- http://dabodev.com |