Why is __debug__ not in the keywords list when it's a keyword?

Viewed 448

__debug__ is a built-in constant, which, according to the docs on constants, doesn't seem like an implementation detail.

When trying to assign to it (which isn't supported as the docs state) the following error message is displayed:

>>> __debug__ = False
  File "<stdin>", line 1
SyntaxError: assignment to keyword

Apparently, according to the message, it's a keyword, but:

>>> from keyword import kwlist
>>> '__debug__' in kwlist
False

Which seems odd. None, True and False, also listed as constants, are contained in the kwlist.

Why isn't __debug__ in the keyword list?

1 Answers
Related