Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #196983
| From | Mild Shock <janburse@fastmail.fm> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Two aces up Python's sleeve (Posting On Python-List Prohibited) |
| Date | 2024-11-08 02:40 +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> |
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