Skip to content
Advertisement

What is __peg_parser__ in Python?

I was using the keyword built-in module to get a list of all the keywords of the current Python version. And this is what I did:

JavaScript

And in the keyword.kwlist list there is __peg_parser__. So to see what it does, I type __peg_parser__ in a Python 3.9 interpreter on Windows (you’ll get the same output on Mac OS and Linux as well), and this is what is get:

JavaScript

So my question is, what is __peg_parser__ and why do I get SyntaxError: You found it!?

Advertisement

Answer

It was an easter egg related to the rollout of the new PEG parser. The easter egg, along with the old LL(1) parser, will be removed in 3.10.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement