handling many default values

Alan Isaac aisaac at american.edu
Sat Nov 11 16:11:38 EST 2006


"Steven D'Aprano" wrote
> (1) If there really is no alternative to a class with many arguments;
> (2) and instances can vary those arguments unpredictably;
> then this approach seems reasonable to me. But I really suggest you
> rethink your class design.

Thanks to all who replied and to George for his specific example.
Steve's comments seem to summarize the overall sentiment:
there is no *general* objection, but I should make sure my
specific implementation really profits from a parameter holding class
(rather than, e.g., a super class in which appropriate defaults are set).
I believe this is the case, since the many parameters can vary
arbitrarily and do not fall into neat groupings.

Also, as an aside, no one objected to using
    self.__dict__.update(kwargs)
in the __init__ function of the parameter holding class.

Thanks,
Alan





More information about the Python-list mailing list