[Python-ideas] Syntax: 'return: ...' expressions

Franklin? Lee leewangzhong+python at gmail.com
Tue Jan 20 18:15:44 CET 2015


On Fri, Jan 9, 2015 at 3:46 AM, Andrew Barnert
<abarnert at yahoo.com.dmarc.invalid> wrote:
>
> I believe the distinction isn't just there to keep the parser simpler, or because Guido wasn't clever enough to figure out how to embed statements in expressions in an indentation-significant language, or because the examples of Ruby and CoffeeScript didn't exist yet and now it's too late for Python; statements are a big part of what makes Python code more readable than those languages, both in-depth and in a quick scan to see the general flow control and state changes.
>
> But it's hard to explain why. And, even if I manage to explain why _I_ think statements make Python more readable, that's just my opinion; it would be nice to have something that Guido endorsed.
>
> Also, for people who want to suggest changes to Python (or design their own languages), it would be helpful to understand how the distinction fits in with other things. For example, in a pure functional language, there may be no benefit to having statements. In a language where (almost) everything is an expression, having mutating methods return self instead of None wouldn't be nearly as much of a problem. More generally, expression-ness and not-mutating are deeply connected (e.g., comprehensions aren't designed for mutation, loop statements are), but it's not easy to say how. And so on.

Sorry to be late.

Will this Guido post suffice as a substitute?
http://www.artima.com/weblogs/viewpost.jsp?thread=147358

Yawar might also need this, if he chooses to pursue this path.
https://wiki.python.org/moin/AlternateLambdaSyntax


More information about the Python-ideas mailing list