Re:Implementing a C-like for loop in Python
by oplaadpunt on Sunday July 02, 2023 @08:40PM
(#36567374)
Yeah, the difference between manipulating the syntax being the intendend way, and it being possible only through hacking and dark magic is rather stark.
It's fun to know that it is basically possible to do though, and I didn't know python had these obscure parts (ast manipulation and codecs)
Whether manipulating the syntax is encouraged or only possible through black magic, the basic problem which GP was (I think) referring to stays the same: "modified" syntax may look more elegant to whoever wrote it, but probably makes the code harder to read and understand for whoever has to work with it later (and that may be yourself, a few years down the line). Plus of course this makes it easier for bugs to hide in unexpected places...
Whether we actually want people’s custom macros and DSLs in production is another question, tho.