Re: Iterate through a list calling functions

2005-06-05 Thread Kent Johnson
David Pratt wrote: > Hi Kent. Thank you for your reply. I gave this a go but get the > following traceback: > ... > result = validator(name, value) > TypeError: 'str' object is not callable > > Have put validators in list and iterate over it as in following: > > validator_list = > [is

Re: Iterate through a list calling functions

2005-06-05 Thread Kent Johnson
George Sakkis wrote: > That's a typical case for using an OO approach; just make a class for > each validator and have a single polymorphic validate method (I would > make validators __call__able instead of naming the method 'validate'): > > # Abstract Validator class; not strictly necessary but g

Re: Iterate through a list calling functions

2005-06-05 Thread David Pratt
Cool! Many thanks George. Yes this is the way to go - objects. Much better :-) On Sunday, June 5, 2005, at 02:49 PM, George Sakkis wrote: > David Pratt wrote: >> Hi. I am creating methods for form validation. Each validator has its >> own method and there quite a number of these. For each fi

Re: Iterate through a list calling functions

2005-06-05 Thread David Pratt
Hi Kent. Thank you for your reply. I gave this a go but get the following traceback: ... result = validator(name, value) TypeError: 'str' object is not callable Have put validators in list and iterate over it as in following: validator_list = [isContainedIn,isDate,isDecimal,isEma

Re: Iterate through a list calling functions

2005-06-05 Thread George Sakkis
David Pratt wrote: > Hi. I am creating methods for form validation. Each validator has its > own method and there quite a number of these. For each field, I want > to evaluate errors using one or more validators so I want to execute > the appropriate validator methods from those available. I am

Re: Iterate through a list calling functions

2005-06-05 Thread Kent Johnson
David Pratt wrote: > Hi. I am creating methods for form validation. Each validator has its > own method and there quite a number of these. For each field, I want to > evaluate errors using one or more validators so I want to execute the > appropriate validator methods from those available. I