News for hackers. Stuff that matters.
Re:Python Anti-Pattern by EdwardDiego on Wednesday September 15, 2021 @03:26AM (#28536254)
Yep, a renowned Python footgun. Although Lambda container reuse adds a modern twist to it.

Can I ask what editor you were using? Because decent ones should have warned you about mutable default args.

Re:Python Anti-Pattern by davidatbu on Wednesday September 15, 2021 @05:16AM (#28536947)
Shout out to the amazing Pyright, the fast and feature-complete python LSP that you can use with any editor that supports the LSP protocol!
Re:Python Anti-Pattern by valinsky on Wednesday September 15, 2021 @05:46PM (#28544769)
I'm using VSCode with different Python specific extensions, like Pylance which uses Pyright, but it didn't warn me about the mutable function parameter. RIP
Re:Python Anti-Pattern by EdwardDiego on Wednesday September 15, 2021 @11:56PM (#28547811)
Huh, that sucks. I use Intellij Ultimate for pretty much everything, and it (and the Python focused Pycharm) will definitely warn on this particular Python quirk.
Re:Python Anti-Pattern by davidatbu on Thursday September 16, 2021 @02:39AM (#28548787)
You're right, I checked, and pyright only warns about function calls in default arguments, not mutable containers.

I started a discussion in Pyright's repo here[0].

[0] https://github.com/microsoft/pyright/discussions/2306

Re:Python Anti-Pattern by davidatbu on Thursday September 16, 2021 @02:55PM (#28555698)
Thanks to the maintainer's great responsiveness, Pyright will implement such a warning soon: https://github.com/microsoft/pyright/issues/2308