seeking deeper (language theory) reason behind Python design choice

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed May 9 22:08:02 EDT 2018


On Wed, 09 May 2018 22:48:42 +0100, bartc wrote:

> On 09/05/2018 06:44, Steven D'Aprano wrote:
>> On Tue, 08 May 2018 22:48:52 -0500, Python wrote:
>> 
>> 
>> But by the time 1.4 came around, Guido had settled on a clean
>> separation between statements and expressions as part of Python's
>> design.
>> 
>> That separation has gradually weakened over the years,
> 
> Presumably it's non-existent now, as it seems you can type any
> expression as a statement in its own right:

That has always been the case. What I mean is that a few of the pure-
statement features have now gained an expression form.


>> with the addition of the ternary if operator
> 
> If you mean that this is a kind of statement that can be incorporated
> into an expression, then just class it as an operator not a statement.

I called it an operator because it is an operator :-)


To hopefully be more clear, any expression can be used as a statement 
(usually pointlessly). But statements (aside from expressions) cannot be 
used as expressions. There are, however, a small number of statements 
which have gained an equivalent expression form.



-- 
Steve




More information about the Python-list mailing list