Why not allow empty code blocks?
BartC
bc at freeuk.com
Sun Jul 24 06:45:22 EDT 2016
On 24/07/2016 11:35, BartC wrote:
> On 23/07/2016 16:55, Steven D'Aprano wrote:
>> In any case, using "end" instead of "pass" is a poor tradeoff. Instead of
>> needing to use "pass" (say) one time in a thousand when it is needed, you
>> would need to use "end" 999 times in a thousand when it *isn't* needed.
>
> Yes, well, some of us wouldn't mind!
'end' to terminate a block can be emulated of course:
end=0
def fn(a):
if a<=1:
return 1
else:
return fn(a-1)
end
end
And in this example it wouldn't impact on performance as it is not
evaluated.
But although it can make source code look more conventional, it would
not be supported by the language (repeated, out of place or missing
'end' lines are not an error). And an empty block will still need pass.
--
bartc
More information about the Python-list
mailing list