In general, you shouldn't use exec() at all.

First and best option, make self.button be a list of buttons, so that
you can write self.button[index].

You may be working with an object structure you can't control (like
glade or something), in which case use getattr:
    self.grid.add(getattr(self, 'button%d' % index))

You could put this getattr behind a method, so that you don't have to
repeat it at each site where you need to refer to a button by index:

    def button(self, i): return getattr(self, 'button%d' % index)
    ...
    def anothermethod(self):
        self.grid.add(self.button(index))

Jeff

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to