Formatted string to object

Scott David Daniels scott.daniels at acm.org
Mon Jun 26 14:29:26 EDT 2006


janama wrote:
> i can use this:
> aaa = 1
> result = eval("self.b%s.SetBitmapDisabled(self.yellow)" % aaa)
> 
> .... How would i to achieve this with getattr() ?

     result = getattr(self, 'b%s' % aaa).SetBitmapDisabled(self.yellow)

--Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list