What is Nostr?
maegul /
npub1djh…dng7
2024-08-14 09:21:38

maegul on Nostr: I never paid attention to the walrus operator argument in #python nor have I used it ...

I never paid attention to the walrus operator argument in #python nor have I used it much.

But just now, using a walrus operator in a list comprehension with a conditional made me realise that it may have marked the point at which python was no longer a beginner friendly lang.

That the walrus operator has to be used in the conditional and not the expression feels wrong to me but is also "technically correct"(?)

valid:
[r for n in x if (r:=f(n)) < 10]

invalid:
[(r:=f(n)) for n in x if r < 10]
Author Public Key
npub1djhdp58x4aa2a5agvavqha55h9zx74ymvcxj57p6te4e68ng2gcsusdng7