Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #196983
| Path | csiph.com!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 02:40:56 +0100 |
| Message-ID | <vgjq77$aj8c$1@solani.org> (permalink) |
| References | <seven-20241106014329@ram.dialup.fu-berlin.de> <vgg5dn$ij48$1@solani.org> <050c2ce9efd8442fb902ecc926afb1ee42fe6c34.camel@tilde.green> <vgjoe9$2stii$2@dont-email.me> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Fri, 8 Nov 2024 01:40:55 -0000 (UTC) |
| Injection-Info | solani.org; logging-data="347404"; 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:BLstDVwn9CtsYSvj3izfL9G0BtM= |
| X-User-ID | eJwNxsEBwCAIA8CVGkhQxoGi+4/Q3uvkgXgXQ0FdXRTBLutjWg/obXh4Zmf/Tc7u6Z6BC1StCaybFSPbyuMfRVEVHw== |
| In-Reply-To | <vgjoe9$2stii$2@dont-email.me> |
| Xref | csiph.com comp.lang.python:196983 |
Show key headers only | View raw
Well you can use your Browser, since
JavaScript understand post and pre increment:
> x = 5
5
> x ++
5
> x = 5
5
> ++ x
6
So we have x ++ equals in Python:
x + = 1
x - 1
And ++ x equals in Python:
x += 1
x
But I don't know how to combine an
assignment and an expression into one
expession. In JavaScript one can use
the comma:
> x = 5
5
> y = (x += 1, x - 1)
5
> x = 5
5
> y = (x += 1, x)
6
But in Python the comma would create a tuple.
Lawrence D'Oliveiro schrieb:
> On Thu, 07 Nov 2024 12:55:53 +0530, Annada Behera wrote:
>
>> I heard this behavior is because python's integers are immutable.
>
> Nothing to do with that.
>
>> ++x or x++ will redefine 5 to 6, which the interpreter forbids ...
>
> One of those is actually syntactically valid.
>
> It just won’t do what you expect it to do.
>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Two aces up Python's sleeve Mild Shock <janburse@fastmail.fm> - 2024-11-06 17:27 +0100
Re: Two aces up Python's sleeve Annada Behera <annada@tilde.green> - 2024-11-07 12:55 +0530
Re: Two aces up Python's sleeve Mild Shock <janburse@fastmail.fm> - 2024-11-07 15:04 +0100
Re: Two aces up Python's sleeve Greg Ewing <greg.ewing@canterbury.ac.nz> - 2024-11-08 11:15 +1300
Re: Two aces up Python's sleeve dn <PythonList@DancesWithMice.info> - 2024-11-08 13:07 +1300
Re: Two aces up Python's sleeve Mild Shock <janburse@fastmail.fm> - 2024-11-08 01:25 +0100
Re: Two aces up Python's sleeve Mild Shock <janburse@fastmail.fm> - 2024-11-08 01:29 +0100
Re: Two aces up Python's sleeve Mild Shock <janburse@fastmail.fm> - 2024-11-08 01:47 +0100
Re: Two aces up Python's sleeve (Posting On Python-List Prohibited) Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-11-08 01:10 +0000
Re: Two aces up Python's sleeve (Posting On Python-List Prohibited) Mild Shock <janburse@fastmail.fm> - 2024-11-08 02:40 +0100
Re: Two aces up Python's sleeve (Posting On Python-List Prohibited) dn <PythonList@DancesWithMice.info> - 2024-11-09 08:09 +1300
Re: Two aces up Python's sleeve (Posting On Python-List Prohibited) Mild Shock <janburse@fastmail.fm> - 2024-11-08 20:49 +0100
Re: Two aces up Python's sleeve (Posting On Python-List Prohibited) Thomas Passin <list1@tompassin.net> - 2024-11-08 17:00 -0500
csiph-web