[Python-ideas] kwargs for return

Michael Selik mike at selik.org
Sat Jan 26 10:14:06 EST 2019

On Sat, Jan 26, 2019, 6:30 AM Anders Hovmöller <boxed at killingar.net wrote:

> > I don't see anything here that can't be done by returning a dict, a
> > namedtuple (possibly with optional fields), or some other object with
> > named fields. They can be optional, they can have defaults, and you can
> > extend the object by adding new fields without breaking backwards
> > compatibility.
> That assumes you knew before hand to do that. The question is about the
> normal situation when you didn't.
> Also you totally disregarded the call site where there is no way to do a
> nice dict unpacking in python. The tuple case is super special and
> convenient but strictly worse than having properly named fields.
> To me this question sounds like it's about dict unpacking with one special
> case to keep backwards compatibility.

My "destructure" module might help. I was playing around with the idea of
dict unpacking and extended it to a kind of case matching.


Grant Jenks independently came to almost the same idea and implementation.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190126/4383f088/attachment-0001.html>

More information about the Python-ideas mailing list