On Sat, 21 May 2016 08:08 pm, Chris Angelico wrote: > On Sat, May 21, 2016 at 7:56 PM, Steven D'Aprano <st...@pearwood.info> > wrote: >> On Sat, 21 May 2016 02:01 pm, Chris Angelico wrote: >> >>> On Sat, May 21, 2016 at 1:50 PM, Steven D'Aprano <st...@pearwood.info> >>> wrote: >> >>>> Would you classify the second line here: >>>> >>>> print("Hello World!") >>>> pass >>>> >>>> >>>> as a bug? What exactly would your bug report be? "pass statement does >>>> nothing, as expected. It should do nothing. Please fix." >>>> >>> >>> Yes, I would. It's not a bug in Python or CPython - it's a bug in the >>> second line of code there. It implies something that isn't the case. >> >> What do you think it implies? >> >> What part of the docs for "pass" implies this thing? >> >> help("pass"): >> >> ``pass`` is a null operation --- when it is executed, nothing >> happens. It is useful as a placeholder when a statement is >> required syntactically, but no code needs to be executed, for >> example: [examples snipped] > > So why is a statement required syntactically after that print call?
Who said it was required? The docs say that `pass` is useful when a statement is required, not the other way: you can put `pass` anywhere a statement can go, without it being required. > Surely that implies something about the programmer's intent? It > certainly isn't required according to the code you've shown me; and if > someone submitted this code to me, I'd query it ("was there something > else meant to be here?"). Sure. Does that make it a bug? I don't think so. I think that a linter should flag it as unnecessary code, but the compiler certainly shouldn't prohibit it. And a human reviewer might be able to judge whether it belongs or not. Some people might not like "FIXME" or "XXX" comments to flag missing code, and use `pass` statements as placeholders. Who are we to tell them they shouldn't? I think we agree that it's not the compiler's job to enforce good coding standards. -- Steven -- https://mail.python.org/mailman/listinfo/python-list