returning unordered keyword arguments from a function (WAS: Are multiple return values really harmful?)
Fernando Perez
fperez528 at yahoo.com
Thu Nov 18 15:19:58 EST 2004
Steven Bethard wrote:
> My understanding is that this is for efficiency reasons... I remember
> some older discussions, but they're kinda hard to google since 'object'
> isn't a very good query term... Personally, I don't really care about
> being able to assign attributes dynamically to an object() instance, but
> I would like to be able to do something like:
>
> >>> r = object(year=2004, month=11, day=18)
> >>> r.day, r.month, r.year
> (18, 11, 2004)
Given that the necessary class is literally a 3-liner, I'm not sure a language
extension is truly needed:
In [1]: class bunch:
...: def __init__(self,**kw):
...: self.__dict__.update(kw)
...:
In [2]: r=bunch(year=2004,month=11,day=18)
In [3]: r.day,r.month,r.year
Out[3]: (18, 11, 2004)
Cheers,
f
More information about the Python-list
mailing list