Python Forum
Is ::= a typo or actually an operator? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Is ::= a typo or actually an operator? (/thread-7712.html)



Is ::= a typo or actually an operator? - Regulus - Jan-22-2018

I am running python 3.4, and trying to learn how to use the keyword assert. It's featured on the Pythong docs page https://docs.python.org/3/reference/simple_stmts.html#the-assert-statement, section 7.3.

This line is giving me a syntax error:
assert_stmt ::= "assert" expression1 ["," expression2]

Is ::= an operator or a typo? The compiler highlights the first colon when I run it.


RE: Is ::= a typo or actually an operator? - Larz60+ - Jan-22-2018

It's a metasyntax notation called extended Backus-Naur form (EBNF).
The BNF uses the symbols (<, >, |, ::=) for itself, but does not include quotes around terminal strings. This prevents these characters from being used in the languages, and requires a special symbol for the empty string. In EBNF, terminals are strictly enclosed within quotation marks ("..." or '...'). The angle brackets ("<...>") for nonterminals can be omitted.
see: https://www.w3.org/TR/hdml20-6.html#HEADING6-3