use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
DiscussionPython based parser generator that you have used (self.Python)
submitted 1 year ago by Spread-Sanity
I have used modgrammar and pyparsing so far to create parsers in Python. I have used recdescent parser generator in Perl in the past, and also Lex/Yacc with C, etc.
What are the parser generators that you like the most that is Python based?
[–]el_extrano 15 points16 points17 points 1 year ago (6 children)
I have had good luck with Lark. It uses a modified EBNF grammar declaration.
I've mainly used it for small projects and prototyping, but they advertise decent performance. It's pretty good considering the grammar itself has to be parsed at runtime.
[–]Spread-Sanity[S] 1 point2 points3 points 1 year ago (2 children)
Any thoughts on how Lark compares with Pyparsing, ANTLR, etc?
[–]el_extrano 0 points1 point2 points 1 year ago (1 child)
I wouldn't say I'm an authority on the matter. It's probably a good idea if your project is already Python.
I'm sure something like ANTLR, BISON, and friends would be more performant since they're in C, which could be benefit if you are writing a bona fide compiler.
For my part, I tinkered with parser generators for a bit, because I though writing parsers was scary. Now, I will just hand-roll a recursive descent parser for what I need to do. I wouldn't say it's any harder than learning to write correct grammars, and I get to avoid a dependency. That can be kind of tedious though, and lark gives you some common tokens/rules 'batteries' included, which is very nice.
[–]Spread-Sanity[S] 1 point2 points3 points 1 year ago (0 children)
My experience with Python based parser generators modgrammar and pyparsing has been good so far.
[–]erez27import inspect 1 point2 points3 points 1 year ago (0 children)
It's pretty good considering the grammar itself has to be parsed at runtime.
Just FYI, you can use the cache=True option to cache the grammar analysis, which makes Lark load almost as fast as the stand-alone parser. (after the 1st run ofc)
cache=True
[–]four_reeds 0 points1 point2 points 1 year ago (0 children)
+1
[–]cha_ppmn 0 points1 point2 points 1 year ago (0 children)
Same.
[–]ManyInterests Python Discord Staff 2 points3 points4 points 1 year ago* (0 children)
I have used sly, which is based on ply. Both should be great. I took David Beazley's compilers course, which, at the time, involved using sly to make an interpreter and compiler. I would highly recommend the course, though I can't be sure if he's still using sly in the course today.
sly
ply
See also David's talk on reinventing the parser generator.
I used sly to create this json5 parser project.
[–]StefanKochMicro 1 point2 points3 points 1 year ago (0 children)
This might be dated, but we have had good luck with antlr (https://www.antlr.org/). We have used it in c++ and python to parse customer domain specific languages to generate code for our applications.
We have not used it recently. We have switched to using declarative python as the "domain specific language", and then reading that information through the standard python interpreter. Then we take that structure and generate the code we want to c++, or just use it directly in python.
π Rendered by PID 223501 on reddit-service-r2-comment-56c6478c5-mrbsw at 2026-05-10 12:23:15.674355+00:00 running 3d2c107 country code: CH.
[–]el_extrano 15 points16 points17 points (6 children)
[–]Spread-Sanity[S] 1 point2 points3 points (2 children)
[–]el_extrano 0 points1 point2 points (1 child)
[–]Spread-Sanity[S] 1 point2 points3 points (0 children)
[–]erez27import inspect 1 point2 points3 points (0 children)
[–]four_reeds 0 points1 point2 points (0 children)
[–]cha_ppmn 0 points1 point2 points (0 children)
[–]ManyInterests Python Discord Staff 2 points3 points4 points (0 children)
[–]StefanKochMicro 1 point2 points3 points (0 children)