[Tutor] String Substitution
richard
python at keep-trying.com
Mon Jan 19 17:50:57 EST 2004
Greetings,
Thanks for all the help. Just what I was looking
for. Have adapted for my script/form and now
works fine.
Regards
>If you have 19 controls, you should definitely use the
>eval solution. If you're already using Python, then
>you're valueing less code over efficiency (with
>something like C). The speed penalty in this case is
>negligible, but in general, use of eval is
>discourgaged. A different version with (practically)
>no speed penalty, using getattr(), would be
>
>values.append(getattr(self,
>'textCtrl%d'%i).GetValue())
>
>Instead of evaluating the whole thing, this uses a
>more specific (and therefore faster) mechanism to get
>that item from self, and then normal code is used
>GetValue(), so it is at full speed.
>
>Daniel Ehrenberg
>
More information about the Tutor
mailing list