Path: csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'result,': 0.07; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; '~ethan~': 0.09; 'cleaner': 0.16; 'filename:fname piece:signature': 0.16; 'index.': 0.16; 'iterable': 0.16; 'lambda:': 0.16; 'unpacking': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'slightly': 0.19; 'thu,': 0.19; 'feb': 0.22; 'header:User- Agent:1': 0.23; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'returned': 0.30; 'checking': 0.33; 'but': 0.35; 'half': 0.37; 'list': 0.37; 'to:addr:python-list': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'received:173': 0.61; 'more': 0.64; '2015': 0.84; 'technically': 0.84 Date: Wed, 04 Feb 2015 09:09:59 -0800 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: meaning of: line, = References: <657497900.499606.1423060711538.JavaMail.yahoo@mail.yahoo.com> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="FOGdfN6DBSlic3aWku4UQ6GVtDWf3RKQ6" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 56 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1423069811 news.xs4all.nl 2970 [2001:888:2000:d::a6]:56656 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85224 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --FOGdfN6DBSlic3aWku4UQ6GVtDWf3RKQ6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 02/04/2015 07:04 AM, Chris Angelico wrote: > On Thu, Feb 5, 2015 at 1:38 AM, Albert-Jan Roskam wro= te: >> I have also never seen this before, but perhaps this: >> >>>>> f =3D lambda: [42] >>>>> result, =3D f() >>>>> result >> 42 >> >> ... is slightly cleaner than this: >>>>> result =3D f()[0] >>>>> result >> 42 >=20 > They're not technically identical. If the thing returned is > subscriptable (as with your list example), then I would definitely > subscript it rather than unpacking; By unpacking you are also double checking that the returned iterable cont= ains exactly one item; more or less will cause an exception -- you only get half that check if you index. -- ~Ethan~ --FOGdfN6DBSlic3aWku4UQ6GVtDWf3RKQ6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBAgAGBQJU0lJoAAoJENZ7D1rrH75NhyQQAKdpzIFBZx9jif6dCqxdHLRG RXFgu/DUVBa7Vy6XXS58vqAIVZSgP4412C0+A0aVC0p+BFS2gxGYekvtmFKhD4fH fLBz665PTo48kLpqGMajYiugCgzLO54HChut9rCjViX+GWeCT6L+LDr3wA8vAkAp Z/z7LmfeMGoiX0+yRFnV7YkhJ/rm4wrbAlWyKm+j2k4guVzkVXeuytAL2plKoSpn OVPgMwgroUpVhNoVMsVg3BX4xW99093yFTTecL3lQ/GOvb3/93O9w9o6f7OBiD/u x8JSprCNphPsD3zrJ0tLYw9UczK3R75a6sWDRWRuRB8hPNRQWOZ+Uby49bVc8j9q XG6sSFQVnTwLgN/6VXCS2jragSJQnM87okQXcMdsShVP0/5i34pvWCuP62cZNBSf R/msXNTz8ovW2ISXqP8ViNr/gUx3NU2PjSAd4XahItATZNQxJjk3q3cffkP27igf BQlOu4rejxH2nkhnERYh8dqFIVOMNwz6JW/f4VPI8vY0pnpL9OUQNcch0shbhNNS x4eG7tlJMi4Jt4XdKvaCcxYkmfDp5PHQkZHF39FkszS20wIjxkENtFZ0jSGQstLQ nix0OwxtYhvuUudrsIs79qMf2iO5WKwM2/BL4zvdTs8csIJ4tnaR37BG4ttziM6+ A3NRLI54t5hElFhba0sX =tCnx -----END PGP SIGNATURE----- --FOGdfN6DBSlic3aWku4UQ6GVtDWf3RKQ6--