Python: setting two variable values separated by comma in python
Your two snippets do different things: try with a
, b
and c
equal 7
, 8
and 9
respectively.
The first snippet sets three variables in 9
, 8
and 9
. In other words, it is max(a, b)
evaluated before being a
assigned to a value c
. Basically, all it a, b = c, max(a, b)
does is push two values onto the stack; variables a
and b
then assigned to these values when discarded.
On the other hand, running the second snippet sets all three variables to 9
. This is because it is a
set to a value c
before calling the function max(a, b)
.
source to share