| Deutsch English Français Italiano |
|
<vglq12$bqo4$1@solani.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: Mild Shock <janburse@fastmail.fm>
Newsgroups: comp.lang.python
Subject: Re: Two aces up Python's sleeve (Posting On Python-List Prohibited)
Date: Fri, 8 Nov 2024 20:49:55 +0100
Message-ID: <vglq12$bqo4$1@solani.org>
References: <seven-20241106014329@ram.dialup.fu-berlin.de>
<vgg5dn$ij48$1@solani.org>
<050c2ce9efd8442fb902ecc926afb1ee42fe6c34.camel@tilde.green>
<vgjoe9$2stii$2@dont-email.me> <vgjq77$aj8c$1@solani.org>
<59a78893-d96a-4f5b-921f-5ad862449ca2@DancesWithMice.info>
<mailman.88.1731092996.4695.python-list@python.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 8 Nov 2024 19:49:54 -0000 (UTC)
Injection-Info: solani.org;
logging-data="387844"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.19
Cancel-Lock: sha1:zZuRXeCnXC8tvWdCYJNzEc/zqT0=
In-Reply-To: <mailman.88.1731092996.4695.python-list@python.org>
X-User-ID: eJwFwQkBwDAIA0BLlCeAnMIa/xJ2F4aDTUfAg0GsJEvn+M1SWp1eGdgljKF8b1NHnOhte3pHUoRffyvl3B9OahXE
Bytes: 1917
Lines: 34
Ok here you go, the "walrus operator" is
actually a good lead, we have that this
here from JavaScript:
x++
respectively
++x
Can be replaced by the Python expression:
(x := x + 1) - 1
respectively
(x := x + 1)
Here is a test only testing x++:
Python 3.14.0a1 (tags/v3.14.0a1:8cdaca8, Oct 15 2024, 20:08:21)
>>> x = 5
>>> (x := x + 1) - 1
5
>>> x
6
dn schrieb:
.... irrational drivel removed ..> The 'walrus operator' could be applied:
>
> >>> x = 5
> >>> y = (x := x + 1); x
> 6
> >>> x, y
> (6, 6)... irrational drivel removed ..