If continuous assignment in python depends on the order, you should pay attention to the order of continuous assignment in python
For example, expression: a=b=1
Proceed a=1 first
Then b=1
Code:
class Node(): def __init__(self,elem,nextnode=None): self._elem=elem self._nextnode=nextnode a=Node('a') a=a._nextnode=Node('b')
According to understanding: python should first perform a._nextnode=Node(' b'), and then a=Node('b')
But in fact, python first performs a=Node('b'), and then a._nextnode=Node('b')
>>> a is a._nextnode True
So the correct order is a._nextnode=a=Node('b')
The above is the detailed content of Can python assign values continuously?. For more information, please follow other related articles on the PHP Chinese website!