Re: Two aces up Python's sleeve (Posting On Python-List Prohibited)

Liste des GroupesRevenir à cl python 
Sujet : Re: Two aces up Python's sleeve (Posting On Python-List Prohibited)
De : janburse (at) *nospam* fastmail.fm (Mild Shock)
Groupes : comp.lang.python
Date : 08. Nov 2024, 03:40:56
Autres entêtes
Message-ID : <vgjq77$aj8c$1@solani.org>
References : 1 2 3 4
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.19
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.
 

Date Sujet#  Auteur
6 Nov 24 * Two aces up Python's sleeve15Stefan Ram
6 Nov 24 `* Re: Two aces up Python's sleeve14Mild Shock
7 Nov09:25  `* Re: Two aces up Python's sleeve13Annada Behera
7 Nov13:03   +- Re: Two aces up Python's sleeve1Stefan Ram
7 Nov16:04   +* Re: Two aces up Python's sleeve6Mild Shock
8 Nov00:15   i`* Re: Two aces up Python's sleeve5Greg Ewing
8 Nov02:07   i +- Re: Two aces up Python's sleeve1dn
8 Nov02:25   i `* Re: Two aces up Python's sleeve3Mild Shock
8 Nov02:29   i  `* Re: Two aces up Python's sleeve2Mild Shock
8 Nov02:47   i   `- Re: Two aces up Python's sleeve1Mild Shock
8 Nov03:10   `* Re: Two aces up Python's sleeve (Posting On Python-List Prohibited)5Lawrence D'Oliveiro
8 Nov03:40    `* Re: Two aces up Python's sleeve (Posting On Python-List Prohibited)4Mild Shock
8 Nov21:09     +* Re: Two aces up Python's sleeve (Posting On Python-List Prohibited)2dn
8 Nov21:49     i`- Re: Two aces up Python's sleeve (Posting On Python-List Prohibited)1Mild Shock
9 Nov00:00     `- Re: Two aces up Python's sleeve (Posting On Python-List Prohibited)1Thomas Passin

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal