I think the most absurd syntax goes to Python again.
Python offers an "extended" form of list comprehensions that lets you combine iteration over nested data structures.
The irony is that the extensions have a left-to-right order again, but because you have to awkwardly combine them with the rest of the clause that is still right-to-left, those comprehensions become completely unreadable unless you know exactly how they work.
E.g., consider a list of objects that themselves contain lists:
I've taken to writing complex comprehensions like this over multiple lines (which I initially thought wasn't possible!). It's still a bit awkward, but the order of "fors" is the same as if one was writing nested for loops, which makes reasoning about it easier for me.
> The proper way to parse or construct nested list comprehensions as explained in pep 202 is to think like you're using normal for:
A syntax construct that requires you to think in a different syntax construct to understand it is not a good syntax construct.
> Everything stays the same except the "use" part that goes in the front (the rule also includes the filters - if).
Yeah, you consistently have to write the end first followed by the start and then the middle, it's just in most cases there's no middle so you naturally think you only have to flip the syntax rather than having to write it middle-ended like a US date.
Python offers an "extended" form of list comprehensions that lets you combine iteration over nested data structures.
The irony is that the extensions have a left-to-right order again, but because you have to awkwardly combine them with the rest of the clause that is still right-to-left, those comprehensions become completely unreadable unless you know exactly how they work.
E.g., consider a list of objects that themselves contain lists:
To get a list of lists of tools, you can use the normal comprehension: But to get a single flattened list, you'd have to do: Where the "t for b" looks utterly mystifying until you realize the "for" clauses are parsed left-to-right as while the "t" at the beginning is parsed right-to-left and is evaluated last.