3 ms·
for i in range(10): print(i) But what would that return? [None] * 10? The limited whitespace-based syntax limits the potential for fun inline statement things
by nerdponx 3y ago
for i in range(10): print(i)
But what would that return? [None] * 10?
The limited whitespace-based syntax limits the potential for fun inline statement things, but it also completely dodges the question of what any particular statement should evaluate to when used as an expression.
- eru 3y ago> But what would that return? [None] * 10? Yes, I guess something like that. That was just meant as an example of how existing Python allows you to write loops on one line. It's not a good example for a meaningful comprehension in our alternative made-up Python dialect. > The limited whitespace-based syntax limits the potential for fun inline statement things, [...] Python already mostly allows you to use parens to override the indentation. They would just need to generalise that a bit. Btw, Haskell already does that: Officially, Haskell has a syntax with curly braces and semicolons; and they define the indentation based syntax as syntactic sugar that desugars to ; and {}. But almost everyone uses indentation based syntax. The exception are perhaps code generators and when posting on a website that messes with indentation. (And, because it's Haskell, the {}; syntax is just another layer of syntactic sugar for 'weird-operator'-based based syntax like >>=.)