Reputation: 9680
I know that assignment is a statement in Python, i.e., it doesn't evaluate to a value unlike an expression. How does the following line of code work in Python, then? Please explain what happens internally in the Python interpreter (lexing, parsing, formation of abstract syntax tree).
# this works
spam = eggs = 'ham'
# this doesn't work. Throws SyntaxError
spam = (eggs = 'ham')
Upvotes: 7
Views: 6093