'How did print(*a, a.pop(0)) change?
This code:
a = [1, 2, 3]
print(*a, a.pop(0))
Python 3.8 prints 2 3 1 (does the pop before unpacking).
Python 3.9 prints 1 2 3 1 (does the pop after unpacking).
What caused the change? I didn't find it in the changelog.
Edit: Not just in function calls but also for example in a list display:
a = [1, 2, 3]
b = [*a, a.pop(0)]
print(b)
Prints [2, 3, 1] vs [1, 2, 3, 1]. And Expression lists says "The expressions are evaluated from left to right" (that's the link to Python 3.8 documentation), so I'd expect the unpacking expression to happen first.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
