Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #110524

Re: Proposal: named return values through dict initialization and unpacking

From Joonas Liik <liik.joonas@gmail.com>
Newsgroups comp.lang.python
Subject Re: Proposal: named return values through dict initialization and unpacking
Date 2016-06-26 18:50 +0300
Message-ID <mailman.7.1466956217.2358.python-list@python.org> (permalink)
References <CALyUfwV9jO0xjSz_Qhk3ox=rJCcAsBE+iU2WzcmXtCEwZS+xEQ@mail.gmail.com> <mailman.0.1466494641.11516.python-list@python.org> <9bf8880c-12ce-4155-b70d-4e63460ee464@googlegroups.com> <CAB1GNpR_1VJyiweqB+RFW=BYHhukw3v8bf3W78VEXOTWJHQ5zA@mail.gmail.com>

Show all headers | View raw


On 26 June 2016 at 18:28, Ari Freund via Python-list
<python-list@python.org> wrote:
> Thanks everybody.  There seems to be a lot of resistance to dict unpacking, in addition to the problem with my proposed shorthand dict() initialization syntax pointed out by Steven D'Aprano, so I won't be pursuing this.
> --
> https://mail.python.org/mailman/listinfo/python-list

something like:

a, b, c = my_magic_reordering_func(mydict, ["alpha", "beta", "charlie"])

..is not too far off, altho it is a little repetitive is is trivial to
write in current python and reaches the goal of insulating you from
some degree of change in the return value. can also be extended to
work with namedtuple for example (which you probably should already be
using if you want to return so many arguments that this is a problem,
returning several arguments is already returning a tuple under the
hood afterall)

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Proposal: named return values through dict initialization and unpacking Ari Freund <arief@google.com> - 2016-06-21 10:34 +0300
  Re: Proposal: named return values through dict initialization and unpacking Steven D'Aprano <steve@pearwood.info> - 2016-06-22 11:35 +1000
    Re: Proposal: named return values through dict initialization and unpacking Michael Selik <michael.selik@gmail.com> - 2016-06-26 18:17 +0000
  Re: Proposal: named return values through dict initialization and unpacking arief@google.com - 2016-06-26 08:28 -0700
    Re: Proposal: named return values through dict initialization and unpacking Joonas Liik <liik.joonas@gmail.com> - 2016-06-26 18:50 +0300

csiph-web