executing list of methods (and collecting results)

David wizzardx at gmail.com
Fri Sep 21 22:16:36 CEST 2007

> I wondering if is this a good pattern to apply, i like the way it looks
> like, at least to me it looks `natural', but...im calling every method
> twice here? One in v_dict and again on the dict iteration?
> Any suggestion will be great!

Another suggestion is to use a naming convention for your validators.
Then you don't need a separate dict that lists them. Just run through
your module or class dict and process each method/function whose name
starts with a certain pattern. You can also cache the names the first
time round so you don't have to match string patterns every time that
collect_validators() runs.

More information about the Python-list mailing list