(no title)
tyrust
|
7 months ago
I write a decent amount of Python, but find the walrus operator unintuitive. It's a little funky that API_KEY is available outside of the `if`, perhaps because I had first seen the walrus operator in golang, which restricts the scope to the block.
bobbylarrybobby|7 months ago
nomel|7 months ago
Alex3917|7 months ago
This "feature" was responsible for one of the worst security issues I've seen in my career. I love Python, but the scope leakage is a mess. (And yes, I know it's common in other languages, but that shouldn't excuse it.)
dec0dedab0de|7 months ago
But if something fails in a loop running in the repl or jupyter I already have access to the variables.
If I want to do something with a loop of data that is roughly the same shape, I already have access to one of the the items at the end.
Short circuiting/breaking out of a loop early doesn't require an extra assignment.
I really can't see the downside.
tyrust|7 months ago
Python really is a bit of a mess haha.
all2|7 months ago
pletnes|7 months ago
yread|7 months ago
MyOutfitIsVague|7 months ago
slightwinder|7 months ago
martin82|7 months ago
chucksmash|7 months ago
The last time I wrote Python in a job interview, one of the interviewers said "wait, I don't know Python very well but isn't this kinda an old style?" Yes, guilty. My Python dates me.