Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73891
| X-Received | by 10.66.246.229 with SMTP id xz5mr1823696pac.34.1404380101854; Thu, 03 Jul 2014 02:35:01 -0700 (PDT) |
|---|---|
| X-Received | by 10.140.27.182 with SMTP id 51mr24025qgx.8.1404380101803; Thu, 03 Jul 2014 02:35:01 -0700 (PDT) |
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!newsswitch.lcs.mit.edu!ottix-news.ottix.net!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!hn18no2418483igb.0!news-out.google.com!a8ni6411qaq.1!nntp.google.com!i13no5498617qae.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.python |
| Date | Thu, 3 Jul 2014 02:35:01 -0700 (PDT) |
| In-Reply-To | <mailman.11446.1404376617.18130.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=82.245.68.143; posting-account=J_U-0woAAACrUCMCI_QdLAKny8A2zeDX |
| NNTP-Posting-Host | 82.245.68.143 |
| References | <f1cd7efe-d628-4e96-9ed3-79d9a212f768@googlegroups.com> <mailman.11432.1404356297.18130.python-list@python.org> <55f74a23-95ea-4be1-950d-e57e645dab1a@googlegroups.com> <mailman.11446.1404376617.18130.python-list@python.org> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <6ed679b1-c6e1-408e-8167-476b169fa2eb@googlegroups.com> (permalink) |
| Subject | Re: TypeError expected in an augmented assignment |
| From | candide <c.candide@laposte.net> |
| Injection-Date | Thu, 03 Jul 2014 09:35:01 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| Lines | 64 |
| Xref | csiph.com comp.lang.python:73891 |
Show key headers only | View raw
> >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*. This is not my reading. > > 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]) > > OK but this behavior is in conformance with the Reference Manual (cf. your quote above : "when possible, the actual operation is performed in-place"). This is not my point because the doc explictly claims that "an augmented assignment [...] performs the binary operation specific to the type of assignment on the two operands".
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