Why not allow empty code blocks?

Marco Sulla mail.python.org at marco.sulla.e4ward.com
Sun Jul 24 09:11:21 EDT 2016


On 24 July 2016 at 14:48, Chris Angelico <rosuav at gmail.com> wrote:
> Maybe the people who are most worried about this can enact a
> simple rule: no dedent without a blank line? That can easily be
> verified by a script, and it'd protect against most of the given
> examples. It's not too much effort (after any reasonable-sized block
> you'll probably have a blank anyway, so it's only the tiniest of loops
> that would be affected). And no language changes are needed :)

I'm incredibly in favor of such a modification, but maybe this is work
for a linter.

Honestly, I find the "pass" statement very clear and simple. There's
more misleading problems in Python syntax, like this:

someFunction(
    "param1"
    "param2"  # comma missed, there will be only one parameter "param1param2"
)

and this one too:

class Parent(Base):
    __tablename__ = 'parent'
    id = Column(Integer, primary_key=True)
    children = relationship("Child"),  # comma inserted by error.
children will be a tuple and SQLAlchemy will fail with misleading
errors



More information about the Python-list mailing list