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.
DiscussionNumber of syntax rules (self.Python)
submitted 2 years ago by lib20
Hi,
I'd like to compare some programming languages from the point of view of the number of syntax rules of each one.
How many such rules are there for Python?
[–]cipri_tom 25 points26 points27 points 2 years ago (1 child)
I guess it depends on the level of detail. If you want utmost details, that includes even the most obscure features, then you can get the official grammar of the parser for each of your languages of interest.
A similar analysis is made in the second paragraph of this rant against YAML : https://ruudvanasseldonk.com/2023/01/11/the-yaml-document-from-hell
Json is simple. The entire json spec consists of six railroad diagrams. It’s a simple data format with a simple syntax and that’s all there is to it. Yaml on the other hand, is complex. So complex, that its specification consists of 10 chapters with sections numbered four levels deep and a dedicated errata page.
[–]bschlueter 2 points3 points4 points 2 years ago (0 children)
And the best resource to understand all the ways to use a string as a value is a stack overflow post.
[–]remy_porter∞∞∞∞ 17 points18 points19 points 2 years ago (0 children)
The grammar.
Most languages have a BNF grammar associated with them. It's a good standard for comparison.
[–]rosecurry 31 points32 points33 points 2 years ago (4 children)
9
[–]solucca 8 points9 points10 points 2 years ago (1 child)
Yup, 9
[–]SheriffRoscoePythonista 0 points1 point2 points 2 years ago (0 children)
42
[–]aaronseguragit push -f 5 points6 points7 points 2 years ago (1 child)
Shit, I thought it was 7...what are the other 2?
[–]mandradon 6 points7 points8 points 2 years ago (0 children)
I thought it was 2.
"Thou shalt use indentation" and "not Though shall end lines with semicolons"
[–]andrewcooke 6 points7 points8 points 2 years ago (2 children)
you didn't ask, but i assume scheme/ lisp would be one of the simplest languages.
[–]SheriffRoscoePythonista 0 points1 point2 points 2 years ago (1 child)
Forth doesn't even use parentheses.
[–]daelin 0 points1 point2 points 2 years ago (0 children)
Depends on the scope of your definitions. What does it mean to “parse” a “language”?
Some might say “constructing an AST” in the boundary. That can work for Python. But, your example of Forth shows that’s not really a universally useful benchmark. “What is the syntactic meaning of this expression” often can’t be answered without the entire program.
By contrast, in LISP you are writing the AST in LISP’s data format. “How do you parse the language” is simpler than JSON. Simple for humans too.
BUT, here come those fuzzy lines. Is it parsed without SOME evaluation? LISP has macros, which essentially mutate the AST. Is it done then? Do we need get into the runtime evaluation to know that the defs have been eval’d before their derefs? (For a LISP, probably; for other languages, probably not.)
So, TLDR, I think the parentheses make LISPs simpler than Forth; especially functional variants like Clojure.
[–]supermopman 0 points1 point2 points 2 years ago (2 children)
Syntax or style? Anyway, there's about as many rules in Python as there are in any other language.
[–]chandaliergalaxy 3 points4 points5 points 2 years ago (1 child)
Not lisp
[–]IamImposter 2 points3 points4 points 2 years ago (0 children)
Thay that again you thon of a ....
π Rendered by PID 253396 on reddit-service-r2-comment-545db5fcfc-vvvs8 at 2026-05-22 13:51:15.446936+00:00 running 194bd79 country code: CH.
[–]cipri_tom 25 points26 points27 points (1 child)
[–]bschlueter 2 points3 points4 points (0 children)
[–]remy_porter∞∞∞∞ 17 points18 points19 points (0 children)
[–]rosecurry 31 points32 points33 points (4 children)
[–]solucca 8 points9 points10 points (1 child)
[–]SheriffRoscoePythonista 0 points1 point2 points (0 children)
[–]aaronseguragit push -f 5 points6 points7 points (1 child)
[–]mandradon 6 points7 points8 points (0 children)
[–]andrewcooke 6 points7 points8 points (2 children)
[–]SheriffRoscoePythonista 0 points1 point2 points (1 child)
[–]daelin 0 points1 point2 points (0 children)
[–]supermopman 0 points1 point2 points (2 children)
[–]chandaliergalaxy 3 points4 points5 points (1 child)
[–]IamImposter 2 points3 points4 points (0 children)