Carlos Gouveia
Carlos Gouveia

Reputation: 279

Whatever happened to package 'parser' in Python 3.10?

This used to work in Python 2:

>>> import parser

But now in Python 3.10 I get an error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'parser'

Whatever happened to this package? It seemingly vanished. What package should I import to have the same functionalities of the old parser?

Thanks.

Upvotes: 1

Views: 3716

Answers (1)

sj95126
sj95126

Reputation: 6908

parser has been deprecated and was removed in Python 3.10. From the v3.9 release notes:

Python 3.9 uses a new parser, based on PEG instead of LL(1). The new parser’s performance is roughly comparable to that of the old parser, but the PEG formalism is more flexible than LL(1) when it comes to designing new language features. We’ll start using this flexibility in Python 3.10 and later.

The ast module uses the new parser and produces the same AST as the old parser.

In Python 3.10, the old parser will be deleted and so will all functionality that depends on it (primarily the parser module, which has long been deprecated).

Upvotes: 6

Related Questions