[Biopython-dev] checker_function for the options in
bio.application.abstractCommandline
Bartek Wilczynski
bartek at rezolwenta.eu.org
Fri Jul 18 12:45:02 EDT 2003
Hello,
I think, there's something not exactly consistent about the parameter setting in
AbstractCommandline class. The problem i see is the following code in the
set_parameter method:
if parameter.checker_function is not None:
paramater.checker_function(value)
parameter.value = value
if we put it together with the documentation of a checker_function:
o checker_function -- a reference to a function that will determine
if a given value is valid for this parameter.
it is at least confusing.
I'm not sure, whether the author meant checker_function to raise an exception when
the parameter is not valid, or he just forgot to put the value assignement into
another if-then statement with the result of checker_function as condition, but
I would really appreciate if someone made it more clear.
I would rather opt for the if-then statement, because it allows me to write
simple and self-explanatory checker functions like
lambda x : isinstance(x,int)
and not to bother with raising the exception. the code in the set_parameter
could look then like:
if parameter.checker_function is not None:
if paramater.checker_function(value):
parameter.value = value
else:
raise ValueError("Invalid parameter value " + repr(value) + " for parameter
" + name)
--
regards
Bartek Wilczyñski
More information about the Biopython-dev
mailing list