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]
--
http://mail.python.
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)
resul
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 func
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):
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 ex
> 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 f
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