[Python-ideas] Syntax: 'return: ...' expressions
ncoghlan at gmail.com
Wed Jan 7 07:15:32 CET 2015
On 7 January 2015 at 15:29, Yawar Amin <yawar.amin at gmail.com> wrote:
> Not exactly, I think ... I just wanted a way to 'wrap' statements inside
> expressions. That would unify the two concepts in Python
The data modelling and control flow aspects of Python, as represented
by statements, are deliberately distinct from the computational
aspects, as represented by expressions.
Some constructs blur the boundaries between computation, data
modelling and control flow, and hence may exist in both statement and
The fact that it permits data modelling and control flow constructs to
be embedded inside computational ones is an argument *against* your
proposal, not one in its favour.
> and make it much more expressive.
Allowing data modelling and control flow constructs to be embedded
inside expressions doesn't make the language more expressive overall,
it just lets you do more within a single expression without giving the
results of suboperations names and/or factoring them out into separate
The number of cases where executing a suboperation first and binding
the result to a name even arguably reduces clarity are relatively few
and far between, and better represented in PEPs like 403 and 3150 than
they are in a general purpose statement-as-expression syntax.
So if you're interested in pursuing this further, I suggest focusing
on the possible pragmatic benefits of defining a standard way to
tunnel Python code through whitespace insensitive contexts and
reformat it with a pretty printer at the far end, rather than the far
more nebulous concept of expressiveness.
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas