Am 11.12.2015 um 17:10 schrieb ICT Ezy:
Dear All,
Very Sorry for the my mistake here. I code here with mu question ...

My Question:

A,B=C,D=10,11
print(A,B,C,D)
#(10,11,10,11) --> This is OK!

a=1; b=2
a,b=b,a
print(a,b)
# (1,2) --> This is OK!

x,y=y,x=2,3
print(x,y)
# (3,2) --> Question: How to explain it?
# Not understand this process. Pl explain ...

What else would you expect?

Assigning goes from right to left:

x,y=y,x=2,3

<=>

y, x = 2, 3
x, y = y, x

Otherwise the assignment x, y = y, x would not make any sense, since x and y haven't any values yet.

And the execution from right to left is also a good choice, because one would like to do something like:

x = y = z = 0

Again, assigning from left to right woud lead to errors.

--
Robin Koch
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to