Re: Formatted string to object

2006-06-26 Thread janama
Thankyou everyone for help last time: The following works ok when setting a wx.lib.buttons.GenBitmapTextButton's disabled bitmap in using wxpython instead of this: self.b1.SetBitmapDisabled(self.yellow) i can use this: aaa = 1 result1 = eval(self.b%s.SetBitmapDisabled(self.yellow) % aaa) result

Re: Formatted string to object

2006-06-26 Thread Scott David Daniels
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 [EMAIL PROTECTED] --

Formatted string to object

2006-06-19 Thread janama
Hi, can such a thing be done somehow? aaa = self.aaa bbb = %s.%s % ('parent', 'bbb') Can you use strings or %s strings like in the above or aaa = 'string' aaa.%s() % 'upper' Somehow? Thanks for taking a look at this Regards Janama -- http://mail.python.org/mailman/listinfo/python-list

Re: Formatted string to object

2006-06-19 Thread Tim Chase
Can you use strings or %s strings like in the above or aaa = 'string' aaa.%s() % 'upper' Somehow? Looks like you want to play with the eval() function. aaa = 'hello' result = eval(aaa.%s() % 'upper') result 'HELLO' Works for your second example. May work on your first example

Re: Formatted string to object

2006-06-19 Thread bruno at modulix
Tim Chase wrote: Can you use strings or %s strings like in the above or aaa = 'string' aaa.%s() % 'upper' Somehow? Looks like you want to play with the eval() function. aaa = 'hello' result = eval(aaa.%s() % 'upper') result 'HELLO' Using eval() or exec should be really avoided

Re: Formatted string to object

2006-06-19 Thread Steven Bethard
janama wrote: can such a thing be done somehow? aaa = self.aaa bbb = %s.%s % ('parent', 'bbb') Can you use strings or %s strings like in the above or aaa = 'string' aaa.%s() % 'upper' Use the getattr() function:: class parent(object): ... class bbb(object): ...

Re: Formatted string to object

2006-06-19 Thread bruno at modulix
janama wrote: Hi, can such a thing be done somehow? aaa = self.aaa bbb = %s.%s % ('parent', 'bbb') Given the first line, I assume this is inside a method body, and parent is a local var. Then the answer is: bbb = getattr(locals()['parent'], 'bbb') read the doc for these two functions