[BangPypers] Multiple return values from a function : Where to draw the line ?
Noufal Ibrahim KV
noufal at nibrahim.net.in
Fri May 23 09:53:04 CEST 2014
On Fri, May 23 2014, Rohit Chormale wrote:
> How is it if you use DataContainer class & set attributes of that class.
> Something like,
> class Data(object):
> def __init__(self, **kwargs):
> object.__setattr__(self, 'attribs', kwargs)
> def __getattr__(self, item):
> if item in self.attribs:
> return self.attribs[item]
> raise AttributeError
> def __setattr__(self, key, value):
> if key in self.attribs:
> self.attribs[key] = value
> object.__setattr__(self, key, value)
You could cheat by doing this.
def __init__(self, **kwargs):
self.__dict__ = kwargs
instead of the above implementation. It's, of course, untested and
More information about the BangPypers