Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #85216
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <fomcl@yahoo.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.047 |
| X-Spam-Evidence | '*H*': 0.91; '*S*': 0.00; 'result,': 0.07; 'wednesday,': 0.07; 'line:': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; '1:08': 0.16; 'ast': 0.16; 'cleaner': 0.16; 'comma': 0.16; 'command:': 0.16; 'expecting': 0.16; "function's": 0.16; 'iterable': 0.16; 'lambda:': 0.16; 'unpack': 0.16; 'why,': 0.16; 'wrote:': 0.18; 'slightly': 0.19; 'thu,': 0.19; 'feb': 0.22; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'equivalent': 0.26; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'work.': 0.31; 'yields': 0.31; '-----': 0.33; 'except': 0.35; 'but': 0.35; 'there': 0.35; 'returning': 0.36; 'url:org': 0.36; 'subject:': 0.39; 'received:67.195': 0.60; 'received:98.137': 0.60; 'here:': 0.62; 're:': 0.63; 'to:addr:gmail.com': 0.65; 'dont': 0.67; 'header :Reply-To:1': 0.67; 'email addr:python.org"': 0.68; 'line,': 0.68; 'of:': 0.68; 'received:gq1.yahoo.com': 0.68; 'received:mail.gq1.yahoo.com': 0.68; 'unusual': 0.74; 'saw': 0.77; '2015': 0.84; 'compare:': 0.84; 'received:bullet.mail.gq1.yahoo.com': 0.84; 'same,': 0.91; 'thing,': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1423060916; bh=KD4oNSPyoma/hRFTcOnlq+e+3EtdC6Raztlddc3oDSc=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject; b=pGvlwb3FdCtNGjAFkKW1+vL6rty4WcHEuo04HlwQpkcl5imxc++f/GYXyZgO28v4jO24FgiA09hOS5rpi3CFKJWmHpY0dA6GYOSWai7bDyZgWU+v9ZcoXPuNEkkeEEeUWhz6Zhse56v5z4pKd5wP9fyVLbPi2JSMGXrHIGTrpyjAD3H/2/IZZzV6RqMtXPy1MdubqYaFFVp7GRugApR4lCjaw+AVjCvhnw0j2gFN4epKF5I/elh/t4FAq5d0Hrvnam2Si6a2HkJnRUE38Uw6t7D3a3hwdDu0BwMjPVh7TJ1l4mj52VIHDkAPzoW2TRKRDwAoN28Q2fG9MyYsYCBxAg== |
| X-Yahoo-Newman-Property | ymail-4 |
| X-Yahoo-Newman-Id | 454472.46878.bm@omp1035.mail.gq1.yahoo.com |
| X-YMail-OSG | LrmV.24VM1l1wmMZAlD2TqMaJmJRliEHmTu_J3nkv8H3FarA3SB07otmGCRzr5O avrj2iiuf4oYcKgWDxLSNJjmYnJv6v75Tjkk9zSn67IIyC6gKwvZOGp_dhPdHK7dlWuRCIg.dQMC YSXMgA1yWVOfw64n1ncenmWZXvOWxF3I1tIBlGKt90SHefJ2s7gwEQL7tu.3Wy_3c6iJWcZuBcNF zgLEJoDUNhcghwmP5HhbJ2AJHGS3HHGguSpa_Gh52ubix2IucVuHsSlxJbfKZXFdxRIs7k4B3Qu_ e4FMfbtYqm7gdzQ8AAiXqVIVV6mwIO.7kpOFrIYFywsJuPGNu8Zc1XVksjlGjCi_Hs_m38.xYN1C slySYfl96XuI2nZIY.bXpu1eAfJjt0ruypeVU6jjnpw.MMfiPLQ4lHGmrDIHoBqsLI37vN_ZixC_ GLNn6DigiPbkJ5pCVP84sSK0WYrrf_TZIzjQq3_GV94xAXRvzDwOdsJQM7DI1KH9.6BzPO1aaj6M P.5jP52rs6BLDDjMFzIl6QHd5R8.9JTIx_cEaKmWtwkDdptpiJjQwJhFwZRZ4652_dPRHJ4oBWdB HZDGRZgsimgkG9nLnTaFSPe3JTjN4d3Iv7xbGmfrmI3FR3jjZojfxJcW9NV7J1cxPG3F2oWEXsT. UE9Ry02._u0Hc |
| Date | Wed, 4 Feb 2015 14:38:31 +0000 (UTC) |
| From | Albert-Jan Roskam <fomcl@yahoo.com> |
| To | Chris Angelico <rosuav@gmail.com> |
| In-Reply-To | <CAPTjJmpqx1Cmm89Lg6-XL4-xdM+xD6=GHKvWb2zYTe4=11ZPPg@mail.gmail.com> |
| References | <CAPTjJmpqx1Cmm89Lg6-XL4-xdM+xD6=GHKvWb2zYTe4=11ZPPg@mail.gmail.com> |
| Subject | Re: meaning of: line, = |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| Cc | "python-list@python.org" <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | Albert-Jan Roskam <fomcl@yahoo.com> |
| 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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.18464.1423061056.18130.python-list@python.org> (permalink) |
| Lines | 62 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1423061056 news.xs4all.nl 2889 [2001:888:2000:d::a6]:44484 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:85216 |
Show key headers only | View raw
----- Original Message ----- > From: Chris Angelico <rosuav@gmail.com> > To: > Cc: "python-list@python.org" <python-list@python.org> > Sent: Wednesday, February 4, 2015 3:24 PM > Subject: Re: meaning of: line, = > > On Thu, Feb 5, 2015 at 1:08 AM, ast <nomail@invalid.com> wrote: >> I dont understand why there is a comma just after line in the following >> command: >> >> line, = plt.plot(x, np.sin(x), '--', linewidth=2) >> >> >> I never saw that before >> >> Found here: >> > http://matplotlib.org/examples/lines_bars_and_markers/line_demo_dash_control.html >> > > That's a slightly unusual form of unpacking. Compare: > > def get_values(): > return 5, 7, 2 > > x, y, z = get_values() > > This is like "x = 5; y = 7; z = 2", because it unpacks the > function's > return value into those three targets. > > What you have is exactly the same, except that it has only one target. > So it's expecting plt.plot() to return an iterable with exactly one > thing in it, and it'll unpack it and put that thing into line: > > def get_packaged_value(): > return [42] > > x, = get_packaged_value() > > This is equivalent to "x = 42". I don't know matplotlib, so I > don't > know what it's returning or why, but as long as it's iterable and > yields exactly one thing, this will work. I have also never seen this before, but perhaps this: >>> f = lambda: [42] >>> result, = f() >>> result 42 ... is slightly cleaner than this: >>> result = f()[0] >>> result 42
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: meaning of: line, = Albert-Jan Roskam <fomcl@yahoo.com> - 2015-02-04 14:38 +0000
Re: meaning of: line, = Rustom Mody <rustompmody@gmail.com> - 2015-02-04 07:09 -0800
Re: meaning of: line, = Peter Otten <__peter__@web.de> - 2015-02-04 18:36 +0100
Re: meaning of: line, = Chris Angelico <rosuav@gmail.com> - 2015-02-05 08:18 +1100
Re: meaning of: line, = Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-02-05 01:10 -0800
Re: meaning of: line, = Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-05 20:40 +1100
Re: meaning of: line, = Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-05 09:08 -0700
Re: meaning of: line, = Rustom Mody <rustompmody@gmail.com> - 2015-02-05 08:45 -0800
Re: meaning of: line, = Skip Montanaro <skip.montanaro@gmail.com> - 2015-02-05 10:56 -0600
Re: meaning of: line, = Tim Chase <python.list@tim.thechases.com> - 2015-02-05 11:00 -0600
Re: meaning of: line, = Rustom Mody <rustompmody@gmail.com> - 2015-02-05 08:59 -0800
Re: meaning of: line, = Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-02-06 05:09 -0800
Re: meaning of: line, = Rustom Mody <rustompmody@gmail.com> - 2015-02-06 05:20 -0800
Re: meaning of: line, = Rustom Mody <rustompmody@gmail.com> - 2015-02-06 06:03 -0800
Re: meaning of: line, = Tim Chase <python.list@tim.thechases.com> - 2015-02-05 10:21 -0600
Re: meaning of: line, = Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-02-05 17:12 -0800
Re: meaning of: line, = Chris Angelico <rosuav@gmail.com> - 2015-02-06 12:17 +1100
Re: meaning of: line, = Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-02-06 17:52 +1300
Re: meaning of: line, = Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-02-06 12:30 +1300
csiph-web