News for hackers. Stuff that matters.
Re:WTFPython – Understanding Python through surprising snippets by edflsafoiewq on Monday December 23, 2019 @04:23AM (#21862427)
I don't find this at all unexpected. In an imperative language I expect a loop to be implemented by mutating a common variable.
Re:WTFPython – Understanding Python through surprising snippets by owl57 on Monday December 23, 2019 @04:57AM (#21862590)
Imperative loop, maybe. But list comprehensions are a sublanguage imported from Haskell and looking like Haskell, so it's somewhat natural to be surprised by mutable variables here.
Re:WTFPython – Understanding Python through surprising snippets by jakear on Monday December 23, 2019 @04:30AM (#21862459)
Do you perhaps think that because you come from a background in low-level languages?
Re:WTFPython – Understanding Python through surprising snippets by fanf2 on Monday December 23, 2019 @08:50PM (#21869201)
Lua and Perl use fresh variables for each iteration, instead of mutating a shared copy.