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

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Joonas Liik <liik.joonas@gmail.com>
Newsgroups comp.lang.python
Subject Re: Proposal: named return values through dict initialization and unpacking
Date Sun, 26 Jun 2016 18:50:10 +0300
Lines 17
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>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de Dag9mCJxzukVuYypcbu6UwW1tgTDkyFSZv1YTyQl4maQ==
Return-Path <liik.joonas@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'pursuing': 0.07; 'cc:addr :python-list': 0.09; 'dict': 0.09; 'tuple': 0.09; 'python': 0.10; 'syntax': 0.13; 'value.': 0.15; '2016': 0.16; 'cc:name:python': 0.16; 'everybody.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'shorthand': 0.16; 'subject:values': 0.16; 'wrote:': 0.16; 'pointed': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'proposed': 0.20; 'arguments': 0.22; 'subject:skip:i 10': 0.22; 'seems': 0.23; 'header:In-Reply-To:1': 0.24; 'example': 0.26; '(which': 0.26; 'skip:m 30': 0.27; 'message-id:@mail.gmail.com': 0.27; 'reaches': 0.27; 'this.': 0.28; 'url:mailman': 0.30; 'probably': 0.31; 'problem': 0.33; 'url:python': 0.33; 'steven': 0.33; 'url:listinfo': 0.34; 'received:google.com': 0.35; 'returning': 0.35; 'something': 0.35; 'too': 0.36; 'should': 0.36; 'there': 0.36; 'url:org': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; "won't": 0.38; 'several': 0.38; 'url:mail': 0.40; 'some': 0.40; 'goal': 0.64; 'python-list': 0.66; 'dict()': 0.84; 'freund': 0.84; 'hood': 0.84; 'off,': 0.84; 'resistance': 0.84; 'to:addr:google.com': 0.84; 'subject:Proposal': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=a6+rglR2W3Bow3r7zLnRH5310v/m3NeQcrfmi5PcxmQ=; b=e3tMvyC2izJqISCrtZeJMLJRXwGzCuIGKEw/prMIyl5B/tzfCa/CO89lS0JscQAqxz cY7okLoUGJHa/4xw92yr5OHwiPzLC73o1LTKMB3qc0xn+QSs8aey7+hQ7lwZ+FWEFTwC dMw8UUWda4JY9UJm54OlxKJUT5gWwoQ0Gju6uttFxGIyBX9CB633VNnXnOJ+ezZt3iS4 DYf+lSZ/PKmeo3cPQYe2sR0vhhGielZNbta5lju/87o+uDMivpyE1M7qqTmyzY9t+Fja lFk1gPxBZAzHY0W/LI8IDfnvnxD81id7lZ9HpCAN2DFHWGAlpyQx7cIHAUisp4TWvBEW p4hA==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=a6+rglR2W3Bow3r7zLnRH5310v/m3NeQcrfmi5PcxmQ=; b=DA/kl4d/MIoL5hC3xVSh3/Iy+JkT2o5X1K9vxhXLRgoJ+QB7Bg6M9YPe7OV9pBuWja RuAqOuDhNVCwIDsdgmYC8wFGnvX/TwBP0yt8VZ4TBgYeUJ5lxJ4ozIMdu35QcRnbeCNg ZgscnNzz4mD9WnXYajXV5KmviHedqeU+H5KkYVfOLPeGPbiRJCcn2VnD3AzbayAKG5Wi KWWg7Sl5ivm963LdaKKQdmm1WmendDk0pDZxl38DsZErt9Rd+nwaCQcEE1FoFQrz6CNc dC5NFA5ohc1BNda1qAZm5IcPKZICsM5zCtnvH4vUYhhqLsLQK8DzNoWKTL7BIuRqdou+ BICA==
X-Gm-Message-State ALyK8tJUT0GOwBX8M8YtPAWR0NdEm4RXal90RbTeZb0FYr0d3Yrv/FxuRuTh32sU/IpkGpUr5Uj1B3rPRvLh7Q==
X-Received by 10.107.173.196 with SMTP id m65mr14382827ioo.131.1466956211418; Sun, 26 Jun 2016 08:50:11 -0700 (PDT)
In-Reply-To <9bf8880c-12ce-4155-b70d-4e63460ee464@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <CAB1GNpR_1VJyiweqB+RFW=BYHhukw3v8bf3W78VEXOTWJHQ5zA@mail.gmail.com>
X-Mailman-Original-References <CALyUfwV9jO0xjSz_Qhk3ox=rJCcAsBE+iU2WzcmXtCEwZS+xEQ@mail.gmail.com> <mailman.0.1466494641.11516.python-list@python.org> <9bf8880c-12ce-4155-b70d-4e63460ee464@googlegroups.com>
Xref csiph.com comp.lang.python:110524

Show key headers only | 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