, "" Python. Python, , , , , , . python:
>>> 'a', 'b'
:
('a', 'b')
, .
self.a, self.b = self.b, self.a+self.b
:
(self.a, self.b) = (self.b, self.a+self.b)
- , self.b self.a + self.b. ( .)
- , self.a self.b. ( .)
- , self.a self.b . : .
- 0 0 .
- 1 1 .
- Now that both variables of the left tuple are assigned, delete both tuples. New variables remain with the new values.
So, for example, you can do:
>>> a, b = 1, 2
>>> a, b
(1, 2)
>>> a, b = b, a
>>> a, b
(2, 1)
There are still temporary variables in the hood, but you, the programmer, don't have to deal with them.
source
share