Why not allow empty code blocks?
Marko Rauhamaa
marko at pacujo.net
Sat Jul 23 07:49:05 EDT 2016
Chris Angelico <rosuav at gmail.com>:
> On Sat, Jul 23, 2016 at 9:13 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
>>> One less thing to be programmed, one less thing for the user to
>>> remember. Just require pass any time you have an empty block, rather
>>> than try to remember where it is required and were it is optional.
>>
>> Actually, the requirement of a dummy statement is a slight annoyance
>> for the programmer. After deleting a statement, you must see if you
>> have to put in a pass statement. And after adding a statement, you
>> may feel the urge to remove the redundant pass statement.
>
> How often do you actually need empty statements, adding stuff,
> removing stuff, like that? Possibly there's a code smell here.
Quite often. For example:
class ItHitFan(Exception): pass
==>
class ItHitFan(Exception):
def __init__(self, huh):
super().__init__()
self.huh = huh
Marko
More information about the Python-list
mailing list