---
# System prepended metadata

title: python 單行賦值(swap)

---

# python 單行賦值(swap)



```python=
cur.next, prev, cur = prev, cur, cur.next
```


see the exmaple 
![](https://i.imgur.com/tDWubHb.png)


原理：

In simple terms, it pushes the values of a and b on the stack, rotates (swaps) the top two elements, then pops the values again. See also: Python Bytecode Instructions.