Gabriel Genellina wrote:
> At Monday 13/11/2006 13:33, Michele Simionato wrote:
>
> >Alan Isaac wrote:
> > > Also, as an aside, no one objected to using
> > > self.__dict__.update(kwargs)
> > > in the __init__ function of the parameter holding class.
> >
> >It is a common trick, also shown in t
At Monday 13/11/2006 13:33, Michele Simionato wrote:
Alan Isaac wrote:
> Also, as an aside, no one objected to using
> self.__dict__.update(kwargs)
> in the __init__ function of the parameter holding class.
It is a common trick, also shown in the Python cookbook, IIRC. If you
are anal about
Alan Isaac wrote:
> Also, as an aside, no one objected to using
> self.__dict__.update(kwargs)
> in the __init__ function of the parameter holding class.
It is a common trick, also shown in the Python cookbook, IIRC. If you
are anal about
double underscores, you can also use
vars(self).update
"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
Ben Finney wrote:
> "Alan Isaac" <[EMAIL PROTECTED]> writes:
>
> > 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
"Alan Isaac" <[EMAIL PROTECTED]> writes:
> 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.)
Alan Isaac wrote:
> > 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
On Fri, 10 Nov 2006 17:11:24 +, Alan G Isaac wrote:
> My class MyClass reuses many default parameters
> with a small number of changes in each instance.
Let me see that I understand. Are you doing something like this?
# Class takes a lot of arguments
a = MyClass(0, 1, 2, 3, 4, 5, ..., 99)
#
> 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?
>
At Friday 10/11/2006 14:11, Alan G Isaac wrote:
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
argume
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__(se
11 matches
Mail list logo