Why not allow empty code blocks?

BartC bc at freeuk.com
Sat Jul 30 16:22:48 EDT 2016


On 30/07/2016 17:15, Rustom Mody wrote:
> On Saturday, July 30, 2016 at 8:17:19 PM UTC+5:30, Steven D'Aprano wrote:
>> On Sat, 30 Jul 2016 09:39 pm, Rustom Mody wrote:
>>
>>> On Saturday, July 30, 2016 at 4:56:01 PM UTC+5:30, Chris Angelico wrote:
>>>> On Sat, Jul 30, 2016 at 8:15 PM, BartC wrote:
>>>>> Anyway, if you're going to talk about annoying things forced upon you
>>>>> by the language, what about:
>>>>>
>>>>> "()" in "print (x)" for Python 3
>>>>
>>>> Why are you singling out print? It's just a function like any other.
>>>> Are you complaining about the way function calls need parentheses?
>>>
>>> Its a function… ok.
>>> Its ‘just’ a function… Arguable
>>
>> "Granny Weatherwax, you are a natural-born disputant."
>> "I ain't!"
>
> Heh I really aint :D
> At least not for this dispute — its not my baby
> Or rather its a stepbaby of stepbaby
>
> Diff between
> print "x"
> and
> print("x")
> is one char — the closing ‘)’
>
> To make a dispute about that — I’ll leave to BartC!

I'll try to oblige...

The difference between the space and "(" is significant to those who 
can't type! (Or have some difficulty in using a keyboard for any reason. 
Or are trying to eat lunch at the same time.)

A space bar is nice and fat, and doesn't need shifting.

Yes you have to make the effort in most code to type shifted 
punctuation, but there it's worth doing. With 'print', you might be 
adding and removing such statements hundreds of times so that extra 
effort is wasted.

(The situation is worse in C however, where, if you want to even 
temporarily print out two labelled values, it's:

   printf("A= %d, B= %d\n", a, b);

for something that might have a half-life of 20 seconds (it might take 
longer to type it out!). In Python 3 it would be:

   print ("A=", a, "B=", b)

so it's much nicer even with parentheses. So the point I'm making is 
minor. On the other hand, elsewhere I normally type:

   cpl =a, =b

('cpl' is an alias for 'println'. The '=' operator is a gimmick which 
automatically produces a label prefix, so this is equivalent to:

   println "A=", a, "B=", b

))

-- 
Bartc






More information about the Python-list mailing list