Why not allow empty code blocks?
BartC
bc at freeuk.com
Fri Jul 29 16:19:00 EDT 2016
On 29/07/2016 20:43, Terry Reedy wrote:
> On 7/29/2016 4:58 AM, Antoon Pardon wrote:
>> Something like.
>>
>> try:
>> Some code
>> except Some_Exception:
>> # Commented code for when I am debugging <Some code>
>> pass
>
> So put in 'pass' whether or not there is no debugging code,
> commented-out debugging code, or debugging code that runs, or whatever.
But that's inelegant.
The language requires that blocks always contains 1 or more statements.
Fair enough, except that 0 statements are often needed so that a dummy
statement - 'pass' - is required just to keep the code legal.
That's untidy, as is your suggestion to keep the dummy statement lying
around anyway so that the number of statements will always be N+1 and
can never reach 0 as N changes.
--
Bartc
More information about the Python-list
mailing list