What is the difference between := and ::= in Python?

1k Views Asked by At

I see Python examples with := and ::=. I've got a good understanding of the walrus operator from an article on RealPython(The Walrus Operator: Python 3.8 Assignment Expressions). I also went through the BNF document in Wikipedia (Backus–Naur form). They seem identical to me. Could anyone please help me to understand the difference between BNF(::=) and the walrus(:=) in Python? It would be great if you can tell me which one I should use in what case with an example?

1

There are 1 best solutions below

0
On

:= is a part of Python syntax, but ::= is not. It was my misunderstanding that I thought the code with ::= was a Python code. It was an explanation about how to use the Python in the document. You won’t see the actual Python code with ::= in it.