News for hackers. Stuff that matters.
Re:XYPlorer Is Written in VB6 by donatj on Saturday January 11, 2025 @09:26AM (#42666087)
In Python, default arguments are mutable. That's the ultimate WTF and footgun.
Re:XYPlorer Is Written in VB6 by orbisvicis on Saturday January 11, 2025 @09:52AM (#42666254)
That's somewhat of misnomer. The root cause is that default arguments are evaluated during function creation rather than when the function called. And... this is invaluable for forcing immediate evaluation of otherwise late-binding closures.

What can be confusing is mixed lifetimes of nested generators using `yield from`. If any outer generator has a shorter lifetime, when it is garbage collected `yield from` will forward `close()` to the inner generator. Attempting to re-use the inner generator will result in a premature `StopIteration`. Iterators do not have `close()` and so are unaffected. This affects only `yield from` and not `for i in gen: yield i`.

Re:XYPlorer Is Written in VB6 by IshKebab on Saturday January 11, 2025 @01:15PM (#42667777)
Yeah that is definitely a footguns but I think calling it the ultimate footgun is overselling it. Perl implicitly casts between strings and integers. That's a waaaay bigger footgun.