[Python-Dev] PEP 559 - built-in noop() (original) (raw)

Steven D'Aprano steve at pearwood.info
Sun Sep 10 21:52:56 EDT 2017


On Mon, Sep 11, 2017 at 07:39:07AM +1000, Chris Angelico wrote:

[...]

As a language change, definitely not. But I like this idea for PYTHONBREAKPOINT. You set it to the name of a function, or to "pass" if you want nothing to be done. It's a special case that can't possibly conflict with normal usage.

I disagree -- its a confusion of concepts. "pass" is a do-nothing statement, not a value, so you can't set something to pass. Expect a lot of StackOverflow questions asking why this doesn't work:

sys.breakpoint = pass

In fact, in one sense pass is not even a statement. It has no runtime effect, it isn't compiled into any bytecode. It is a purely syntactic feature to satisfy the parser.

Of course env variables are actually strings, so we can choose "pass" to mean "no break point" if we wanted. But I think there are already two perfectly good candidates for that usage which don't mix the concepts of statements and values, the empty string, and None:

setenv PYTHONBREAKPOINT="" setenv PYTHONBREAKPOINT=None

-- Steve



More information about the Python-Dev mailing list