On 2024-08-11 15:26, Patrick Rudin <[email protected]> wrote:
> Ich würde auch bei
>
> zahl = 5
> zahl += 1 if zahl > 6 else 6
>
> nicht das erwarten, was rauskommt. Aber man lernt dazu :)

Die Syntax des ternary operators in Python ist IMHO ein Graus.
Ich weiß nicht, was sich Guido dabei gedacht hat.

Allerdings fällt mir als alternative Interpretation nur
    (zahl += 1) if zahl > 6 else 6
also
    if zahl > 6:
        zahl += 1
    else:
        6
ein und das ergibt nicht wirklich viel Sinn ("6" allein in einer Zeile
ist zwar syntaktisch zulässig, tut aber nichts.)

    zahl (+= 1 if zahl > 6 else 6)
ist für mich nicht möglich, weil es gleichbedeutend mit
    if zahl > 6:
        zahl += 1
    else:
        zahl 6
wäre und da fehlt ein Operator zwischen "zahl" und "6".

        hp
_______________________________________________
python-de Mailingliste -- [email protected]
Zur Abmeldung von dieser Mailingliste senden Sie eine Nachricht an 
[email protected]
https://mail.python.org/mailman3/lists/python-de.python.org/
Mitgliedsadresse: [email protected]

Reply via email to