Ricardo Aráoz wrote:
> Paul McNett wrote:
>> Actually, you'd be better off checking that you have an object first:
>>
>> lbl = getattr(self, curlabel, None)
>> if lbl:
>>      lbl.Caption = "somestr"
>>
>> HTH
>>
> 
> How un-pythonic! Use exceptions!

Ok:

   try:
     lbl = getattr(self, curlabel)
   except AttributeError:
     lbl = None

   if lbl:
     lbl.Caption = "somestr"

Please explain why those 6 lines are better than my original 3.


-- 
pkm ~ http://paulmcnett.com


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/dabo-users/[EMAIL PROTECTED]

Reply via email to