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


Groups > comp.lang.python > #85233

Re: meaning of: line, =

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.86.MISMATCH!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'anyway.': 0.05; 'assign': 0.07; 'literal': 0.09; 'pointers': 0.09; 'references.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'behaviour.': 0.16; 'bytecode': 0.16; 'cases)': 0.16; 'created;': 0.16; 'else"': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'tuple': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'alternate': 0.24; 'cc:2**0': 0.24; 'possibly': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; '>>>>': 0.31; 'another': 0.32; 'could': 0.34; "can't": 0.35; 'created': 0.35; 'something': 0.35; 'received:google.com': 0.35; 'yield': 0.36; 'list': 0.37; 'that,': 0.38; "you're": 0.61; 'to,': 0.72; '2015': 0.84; 'otten': 0.84; 'notion': 0.91; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=ayGM1pcB+OUqzEQMyIkyooo2T7rJ+9HI7txfQhgJlhA=; b=N+iV7LbCDhp2Z+/JzZuoqhGktkyPRMcZXse5rOQO4hCYo0dTSAOxOm3A8PId88gMQN UAdrG3ENaWGhSigTUN0l1lwuM7BrYAiz9mlKbvJe4Dlu4I/qi6HNZLeseYGHytdrhIQd NNQvI+LM/9dUHgS4jilHXLQvSKTnj9trKcFDpw+usb8DZfRjyqf2dg4qBzd+GnaqIQ+y zKtTMjIbSfKHwrJ8d8A3JhBRKpGw1k3FgrM3+NnFaLPDv23c1hcSlj/R6S1NOzJA+THT jugIM8+VBlDqqFGKAbugY4zUrsN5jniHI6RDdjV3RcjqHGDy94+1zrGGdN/Z8S+TM1IF MCEg==
MIME-Version 1.0
X-Received by 10.107.167.201 with SMTP id q192mr374047ioe.43.1423084719391; Wed, 04 Feb 2015 13:18:39 -0800 (PST)
In-Reply-To <matlbh$r0s$1@ger.gmane.org>
References <CAPTjJmpqx1Cmm89Lg6-XL4-xdM+xD6=GHKvWb2zYTe4=11ZPPg@mail.gmail.com> <mailman.18464.1423061056.18130.python-list@python.org> <07f4498c-7917-4315-85d4-73283a830f2d@googlegroups.com> <matlbh$r0s$1@ger.gmane.org>
Date Thu, 5 Feb 2015 08:18:39 +1100
Subject Re: meaning of: line, =
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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>
Newsgroups comp.lang.python
Message-ID <mailman.18478.1423084727.18130.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1423084727 news.xs4all.nl 2914 [2001:888:2000:d::a6]:57704
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:85233

Show key headers only | View raw


On Thu, Feb 5, 2015 at 4:36 AM, Peter Otten <__peter__@web.de> wrote:
> Another alternative is to put a list literal on the lefthand side:
>
>>>> def f(): yield 42
>
> ...
>>>> [result] = f()
>>>> result
> 42

Huh, was not aware of that alternate syntax.

> (If you're worried: neither the list nor the tuple will be created; the
> bytecode is identical in both cases)

It can't possibly be created anyway. Python doesn't have a notion of
"assignable thing that, when assigned to, will assign to something
else" like C's pointers or C++'s references. There's nothing that you
could put into the list that would have this behaviour.

ChrisA

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


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