Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73887
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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; '"""': 0.07; 'assignment': 0.07; 'binary': 0.07; 'modified': 0.07; 'plenty': 0.07; '[1,': 0.09; 'assigning': 0.09; 'augmented': 0.09; 'performs': 0.09; 'referenced': 0.09; 'similar,': 0.09; 'target,': 0.09; 'cc:addr :python-list': 0.11; '3],': 0.16; 'effect.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'in- place,': 0.16; 'once.': 0.16; 'ought': 0.16; 'rewritten': 0.16; 'simplest': 0.16; 'wrote:': 0.18; 'possible,': 0.19; 'thu,': 0.19; 'later': 0.20; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'instead.': 0.24; 'cc:2**0': 0.24; 'references': 0.26; 'post': 0.26; 'header:In-Reply-To:1': 0.27; 'feature': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:python': 0.33; 'actual': 0.34; "can't": 0.35; 'equal': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'raising': 0.36; 'url:org': 0.36; 'two': 0.37; 'form,': 0.38; 'version,': 0.38; 'pm,': 0.38; 'rather': 0.38; 'expression': 0.60; 'new': 0.61; 'url:3': 0.61; 'skip:* 10': 0.61; 'first': 0.61; 'skip:n 10': 0.64; 'here': 0.66; 'link:': 0.72; 'jul': 0.74; 'comparable': 0.84; 'distinguish': 0.84; 'object:': 0.84; 'significance': 0.84; 'url:reference': 0.84; '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=dQtehWaIKpcJbNFqNniXESdXovlXi6yCbYZEofWoht0=; b=ylLSJgPT3wT6SFOtTggSfYihbOgoAwrwgD98obz0Uidf4ai/NaKIKPD9RszJZNnltX X3NvaBhm4YNwkdIfR1ogndGqKAU/DHO3/JqNvsGqGsa01fUUMl2yMLoZSJhE0dA5S3Er X2ZSyBDePW2zRosP0f4ICVWdOKKTv5P6WeXeDAKyynW6pQP5RbjHtPNHHMqaknmbtJ3x sQTg/7apq+tuvjwrPpAeJeVciUcaxcEWsZ/mp2PdZ9y5bqEU2S0Ifg/E906OJhYY1sX3 gErfoKlOJMKAeFFqUkn6Flv0BAGgCP9+HIiEc3su+SiOWXEdar5+cGJhy7jGbCJWERgB ohiw== |
| MIME-Version | 1.0 |
| X-Received | by 10.58.160.10 with SMTP id xg10mr2620774veb.0.1404376609376; Thu, 03 Jul 2014 01:36:49 -0700 (PDT) |
| In-Reply-To | <55f74a23-95ea-4be1-950d-e57e645dab1a@googlegroups.com> |
| References | <f1cd7efe-d628-4e96-9ed3-79d9a212f768@googlegroups.com> <mailman.11432.1404356297.18130.python-list@python.org> <55f74a23-95ea-4be1-950d-e57e645dab1a@googlegroups.com> |
| Date | Thu, 3 Jul 2014 18:36:49 +1000 |
| Subject | Re: TypeError expected in an augmented assignment |
| 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.11446.1404376617.18130.python-list@python.org> (permalink) |
| Lines | 36 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1404376617 news.xs4all.nl 2897 [2001:888:2000:d::a6]:43619 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:73887 |
Show key headers only | View raw
On Thu, Jul 3, 2014 at 5:51 PM, candide <c.candide@laposte.net> wrote:
> Good and interesting observation. But I can't find out where this feature is referenced in the Language/Library Reference. Because, as my first post explains, augmented assignment performs the binary operation associated to the augmented assignment, cf.
>
> https://docs.python.org/3.2/reference/simple_stmts.html#augmented-assignment-statements
>
> so seq+= {5, 6} performs seq + {5, 6}, the later raising a TypeError.
>From that link:
"""
An augmented assignment expression like x += 1 can be rewritten as x =
x + 1 to achieve a similar, but not exactly equal effect. In the
augmented version, x is only evaluated once. Also, when possible, the
actual operation is performed in-place, meaning that rather than
creating a new object and assigning that to the target, the old object
is modified instead.
"""
The significance here is that the augmented assignment may not
necessarily be at all comparable to the non-augmented version, but
ought to have *approximately* the same *intention*. There are plenty
of situations where the two will differ, eg when there are multiple
references to the same object:
>>> a = b = [1,2]
>>> a += [3]
>>> a,b
([1, 2, 3], [1, 2, 3])
>>> a = a + [4]
>>> a,b
([1, 2, 3, 4], [1, 2, 3])
In its simplest form, x += 1 <-> x = x + 1, but there are plenty of
ways to distinguish them.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
TypeError expected in an augmented assignment candide <c.candide@laposte.net> - 2014-07-02 19:39 -0700
Re: TypeError expected in an augmented assignment Terry Reedy <tjreedy@udel.edu> - 2014-07-02 22:57 -0400
Re: TypeError expected in an augmented assignment candide <c.candide@laposte.net> - 2014-07-03 00:51 -0700
Re: TypeError expected in an augmented assignment Chris Angelico <rosuav@gmail.com> - 2014-07-03 18:36 +1000
Re: TypeError expected in an augmented assignment candide <c.candide@laposte.net> - 2014-07-03 02:35 -0700
Re: TypeError expected in an augmented assignment Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-07-03 13:43 +0100
csiph-web