"goodwolf" <[EMAIL PROTECTED]> escribió en el mensaje 
news:[EMAIL PROTECTED]
> A simply solution:
>
> def __init__(self, a=1, b=2, c=3, ......):
>    for key, val in locals().items():
>        if key != 'self':
>            setattr(self.__class__, key, val)
>
> in addition:
>
> def set(self, **kwarg):
>    for key in kwargs:
>        if hasattr(self.__class__, key):
>            setattr(self.__class__, key, kwargs[key])
>        else:
>            raise ....

Why setattr(self.__class__,...) instead of setattr(self, ...)? You're 
modifying the class attributes, and that's not usually intended.

-- 
Gabriel Genellina 


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to