handling many default values

Alan G Isaac aisaac at american.edu
Fri Nov 10 12:11:24 EST 2006


My class MyClass reuses many default parameters
with a small number of changes in each instance.
For various reasons I decided to put all the
parameters in a separate Params class, instances
of which reset the default values based on keyword
arguments, like this:

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.)

Thanks,
Alan Isaac



More information about the Python-list mailing list