Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100271
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Python variable assigning problems... |
| Date | Fri, 11 Dec 2015 09:39:17 -0700 |
| Lines | 35 |
| Message-ID | <mailman.144.1449852005.12405.python-list@python.org> (permalink) |
| References | <4b28ee3d-47b3-40ef-b48e-abff720635ed@googlegroups.com> <n4c0of$hqr$1@dont-email.me> <0098ce4a-966b-41df-bf06-352ad451134f@googlegroups.com> <n4etbt$mve$1@news.albasani.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de 7LoD0G4vPZS+1gdZ6N3KbQMW6G+g9x5QNHNnPzS3y0dg== |
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'yet.': 0.03; 'subject:Python': 0.05; 'assignment': 0.07; 'assigning': 0.09; 'nameerror:': 0.09; 'left:': 0.16; 'received:209.85.213.176': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'sense,': 0.16; 'subject:variable': 0.16; 'woud': 0.16; "{'foo':": 0.16; 'wrote:': 0.16; '>>>': 0.20; '2015': 0.20; '"",': 0.22; 'assign': 0.22; 'am,': 0.23; 'defined': 0.23; 'dec': 0.23; "haven't": 0.24; '(most': 0.24; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'fri,': 0.27; 'right.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'errors.': 0.27; 'values': 0.28; 'traceback': 0.33; 'file': 0.34; 'received:google.com': 0.35; 'execution': 0.35; 'something': 0.35; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'no,': 0.38; 'received:209': 0.38; 'mean': 0.38; 'means': 0.39; 'goes': 0.39; 'to:addr:python.org': 0.40; 'to:name:python': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=5xSFuwOC7Yf8Cs+g+RALnKxda0SHCbdoJgt3aByUtDA=; b=MRlIDMs9tauQNcEgdnL/ZUHuhiv7WHWN5sX5tA/uaFKrgVAA4hZn2AVCpTV3LJyIW5 oOahTPHiRqgY6Z1BMJcqeyO4I9ivOVUP3WT8Q9Rqc/NRxlJhqFt0kuIrF/2vBz1ykaV6 YuZQIyjJCjRo9qHqc58UVY0tEKbo1J1RZYo3WlMddM2o2FtatHHey12mlzHWzaYxszvi MMz5+HMFyNxMhfq4DRSyL6itEExj61mOCtrq3hKMiljQ3saiX9sHpU4IP6svFO4I9M6j Srcfq7go493f9/GWVbOjjNdgNdU+9TIzCrfBIsS3SY1mIB5NpUpVGWacqebBRnLt5UMa 2YSQ== |
| X-Received | by 10.50.154.5 with SMTP id vk5mr5611281igb.85.1449851997208; Fri, 11 Dec 2015 08:39:57 -0800 (PST) |
| In-Reply-To | <n4etbt$mve$1@news.albasani.net> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| 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> |
| Xref | csiph.com comp.lang.python:100271 |
Show key headers only | View raw
On Fri, Dec 11, 2015 at 9:24 AM, Robin Koch <robin.koch@t-online.de> wrote:
> Assigning goes from right to left:
>
> x,y=y,x=2,3
>
> <=>
>
> y, x = 2, 3
> x, y = y, x
>
> Otherwise the assignment x, y = y, x would not make any sense, since x and y
> haven't any values yet.
>
> And the execution from right to left is also a good choice, because one
> would like to do something like:
>
> x = y = z = 0
>
> Again, assigning from left to right woud lead to errors.
No, it actually happens left to right. "x = y = z = 0" means "assign 0
to x, then assign 0 to y, then assign 0 to z." It doesn't mean "assign
0 to z, then assign z to y, etc." This works:
>>> d = d['foo'] = {}
>>> d
{'foo': {...}}
This doesn't:
>>> del d
>>> d['foo'] = d = {}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'd' is not defined
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python variable assigning problems... ICT Ezy <ictezy@gmail.com> - 2015-12-09 09:49 -0800
Re: Python variable assigning problems... Joel Goldstick <joel.goldstick@gmail.com> - 2015-12-09 12:51 -0500
Re: Python variable assigning problems... Joel Goldstick <joel.goldstick@gmail.com> - 2015-12-09 12:52 -0500
Re: Python variable assigning problems... Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-12-09 21:38 +0000
Re: Python variable assigning problems... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-12-10 16:33 +1100
Re: Python variable assigning problems... Denis McMahon <denismfmcmahon@gmail.com> - 2015-12-10 14:03 +0000
Re: Python variable assigning problems... ICT Ezy <ictezy@gmail.com> - 2015-12-11 08:10 -0800
Re: Python variable assigning problems... Robin Koch <robin.koch@t-online.de> - 2015-12-11 17:24 +0100
Re: Python variable assigning problems... Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-11 09:39 -0700
Re: Python variable assigning problems... Robin Koch <robin.koch@t-online.de> - 2015-12-11 18:52 +0100
Re: Python variable assigning problems... ICT Ezy <ictezy@gmail.com> - 2015-12-11 10:23 -0800
Re: Python variable assigning problems... ICT Ezy <ictezy@gmail.com> - 2015-12-11 10:05 -0800
Re: Python variable assigning problems... Michael Torrie <torriem@gmail.com> - 2015-12-11 11:20 -0700
Re: Python variable assigning problems... ICT Ezy <ictezy@gmail.com> - 2015-12-11 10:25 -0800
Re: Python variable assigning problems... Jussi Piitulainen <harvesting@is.invalid> - 2015-12-11 20:27 +0200
Re: Python variable assigning problems... ICT Ezy <ictezy@gmail.com> - 2015-12-11 10:54 -0800
Re: Python variable assigning problems... ICT Ezy <ictezy@gmail.com> - 2015-12-11 10:55 -0800
Re: Python variable assigning problems... ICT Ezy <ictezy@gmail.com> - 2015-12-11 10:00 -0800
Re: Python variable assigning problems... Michael Torrie <torriem@gmail.com> - 2015-12-11 11:10 -0700
Re: Python variable assigning problems... Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-11 09:36 -0700
csiph-web