Iterate creating variables?

Diez B. Roggisch deets at
Fri Jun 13 18:03:53 CEST 2008

> Thank you, this is much closer to where I need to be...
> The issue is (and this is the part that you don't know, because I
> didn't tell you!) is that I later need to call methods on
> "self.checkbox1", for instance:
> self.checkbox1.GetValue()
> to determine if the box is checked or not.
> I should have included that piece in the initial problem description;
> my apologies.

Then translate the above to


The point of all this is the following: If you have a variable (even if 
not changing often, or being globally configured) number of objects, 
it's a good idea to keep them around in a list.

Even if you need specific parameters for the checkboxes, it would most 
probably be better to do it like this

checkbox_args = [
   ("name", parameter, ...),
   ("other_name", other_parameter, ...),

for parameters in checkbox_args:

If you know on the other hand that you will have 10 checkboxes which 
have all a defined meaning, it might be better to use a meaningful name 
for them, like:

self.create_backup = Checkbox(...)
self.perform_authorization = Checkbox(...)

More information about the Python-list mailing list