Why is __debug__ not on the keyword list when it is a keyword?

__debug__- built-in constant, which, according to docs on constants , does not look like an implementation detail,

When you try to assign it (which is not supported as the state of documents), the following error message is displayed:

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

Apparently, according to the post, this is a keyword, but:

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

Which seems strange. None, Trueand False, also listed as constants, are contained in kwlist.

Why are there no keywords in the list __debug__?

+4
source share
1 answer

Python. , __debug__, , , __debug__ keyword.kwlist .

+5

Source: https://habr.com/ru/post/1681036/


All Articles