Home  >  Article  >  Backend Development  >  Can python assign values ​​continuously?

Can python assign values ​​continuously?

anonymity
anonymityOriginal
2019-06-15 14:10:155802browse

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

Can python assign values ​​continuously?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn