Python Grammar Railroad Scheme

I am looking for a way to better understand Python grammar. My experience is that a grammar chart can be useful.

The Python documentation contains grammar in text form:

https://docs.python.org/3/reference/grammar.html

But it is not very easy to digest for those who are just starting out with software development.

Does anyone have any good stuff for beginners?

There is a Generation Diagram Generator that I could use, but I could not find the EBNF syntax for the Python grammar to be adopted by this generator. A reference to such a grammar is also very useful.

+4
source share
1 answer

Python, , , https://docs.python.org/3/reference/grammar.html, EBNF, :

  • #... /*...*/ ( )
  • ::= :
  • (...)? [...].

,

# The function statement
funcdef: 'def' NAME parameters ['->' test] ':' suite

/* The function statement */
funcdef ::= 'def' NAME parameters ('->' test)? ':' suite
+1

All Articles