handling many default values

Alan Isaac aisaac at american.edu
Sat Nov 11 08:10:54 EST 2006


> At Friday 10/11/2006 14:11, Alan G Isaac wrote:
> >class Params:
> >      def __init__(self,**kwargs):
> >          #set lots of default values
> >          ...
> >          #set the deviations from defaults
> >          self.__dict__.update(kwargs)
> >
> >Is this a reasonable approach overall?
> >(Including the last line.)


"Gabriel Genellina" wrote in message
news:mailman.2074.1163201795.11739.python-list at python.org...
> I'm not sure what you want to do exactly, but a class attribute acts
> as a default instance attribute.

Yes.  I am sorry my question was not clearer.
There are *many* parameters,
and the list can change,
so I want to avoid listing them all in the Param class's __init__ function,
using the strategy above.

Q1: Is this approach reasonable?
    (This is a newbie question about unforseen hazards.)
Q2: Is it horrible design to isolate the parameters in a separate class?
    (Comment: currently several classes may rely on (parts of) the same
parameter set.)

Thanks,
Alan Isaac





More information about the Python-list mailing list