[issue36000] __debug__ is a keyword but not a keyword

Steven D'Aprano report at bugs.python.org
Fri Feb 15 07:40:41 EST 2019


Steven D'Aprano <steve+python at pearwood.info> added the comment:

I'm not sure that __debug__ is a proper keyword. Unlike None, if you monkey-patch builtins, you can modify it:

py> builtins.__dict__['__debug__'] = 'Surprise!'
py> __debug__
'Surprise!'

py> builtins.__dict__['None'] = 'Surprise!'
py> None
py>


And it is not listed here:

https://docs.python.org/3.7/reference/lexical_analysis.html#keywords

So __debug__ appears to me to be in a strange grey area, part regular name and part keyword, but not quite either.

----------
nosy: +steven.daprano

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36000>
_______________________________________


More information about the Python-bugs-list mailing list