handling many default values

Gabriel Genellina gagsl-py at yahoo.com.ar
Mon Nov 13 14:25:51 EST 2006


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
>double underscores, you can also use
>
>vars(self).update(kwargs)

Not good - that relies on vars() returning the actual __dict__.
 From <http://docs.python.org/lib/built-in-funcs.html>:
"The returned dictionary should not be modified: the effects on the 
corresponding symbol table are undefined."


-- 
Gabriel Genellina
Softlab SRL 

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar



More information about the Python-list mailing list