seeking deeper (language theory) reason behind Python design choice

bartc bc at freeuk.com
Thu May 10 06:02:05 EDT 2018


On 10/05/2018 09:09, Marko Rauhamaa wrote:
> bartc <bc at freeuk.com>:
>> On 09/05/2018 06:44, Steven D'Aprano 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:
>>
>>    "stmt"
>>    a + b*c
>>    p == 0
> 
> When typing in code (in various languages), I have a habit of typing
> "..." at places that need to be implemented. For example:
> 
>      if count:
>          ...
>      else:
>          do_something_smart()
>          break
> 
> the idea being that "..." will surely trigger a syntax error if I forget
> to address it.
> 
> I was mildly amused when Python happily executed such code. "..." is a
> valid expression and thus, a valid statement.

I wondered what it meant, so I typed in:

    print (...)

and it displayed:

    Ellipsis

which wasn't very enlightening.

-- 
bartc





More information about the Python-list mailing list