Re: Two aces up Python's sleeve

Liste des GroupesRevenir à cl python 
Sujet : Re: Two aces up Python's sleeve
De : annada (at) *nospam* tilde.green (Annada Behera)
Groupes : comp.lang.python
Date : 07. Nov 2024, 08:25:53
Autres entêtes
Organisation : tilde.green
Message-ID : <050c2ce9efd8442fb902ecc926afb1ee42fe6c34.camel@tilde.green>
References : 1 2
User-Agent : Evolution 3.52.2
Then please explain why I have to write:
>
    i += 1
>
Instead of the shorter:
>
    i ++
>
My short-term memory is really stressed.

I heard this behavior is because python's integers are immutable.
For example:

    >>> x,y = 5,5
    >>> id(x) == id(y)
    True

5 is a object that x and y points to. ++x or x++ will redefine 5 to
6, which the interpreter forbids to keep it's state mathematically
consistent. Also, by not supporting x++ and ++x, it avoids the pre-
and post-increment (substitute-increment v. increment-substitute) bugs
that plagues C and it's children.



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 Nov 24  `* Re: Two aces up Python's sleeve13Annada Behera
7 Nov 24   +- Re: Two aces up Python's sleeve1Stefan Ram
7 Nov 24   +* Re: Two aces up Python's sleeve6Mild Shock
8 Nov 24   i`* Re: Two aces up Python's sleeve5Greg Ewing
8 Nov 24   i +- Re: Two aces up Python's sleeve1dn
8 Nov 24   i `* Re: Two aces up Python's sleeve3Mild Shock
8 Nov 24   i  `* Re: Two aces up Python's sleeve2Mild Shock
8 Nov 24   i   `- Re: Two aces up Python's sleeve1Mild Shock
8 Nov 24   `* Re: Two aces up Python's sleeve (Posting On Python-List Prohibited)5Lawrence D'Oliveiro
8 Nov 24    `* Re: Two aces up Python's sleeve (Posting On Python-List Prohibited)4Mild Shock
8 Nov 24     +* Re: Two aces up Python's sleeve (Posting On Python-List Prohibited)2dn
8 Nov 24     i`- Re: Two aces up Python's sleeve (Posting On Python-List Prohibited)1Mild Shock
9 Nov 24     `- 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