Python Oddities Explained
summary
Examples and concrete outcomes decide whether to watch: loop variable ends up as 8 after for x in numbers but a list comprehension leaves x at 0 in Python 3, using += inside a function raises an error when it makes the name local, list += mutates the list while tuple += creates a new tuple, list += with a string extends by characters, appending a list to itself makes a recursive structure, and augmented assignment first calls __iadd__ then does an assignment so mutations can happen before an assignment fails.
AI-written summary · about
chapters (5)
related talks
27mPython Oddities Explained
24mPython Peculiarities
21mBecome a Better Pythonista by Abusing List Comprehensions and :=
27mVariables and objects in Python: it's pointers all the way down
01h 18mPython 103: Mmmm... Understanding Python's Memory Model, Mutability, and Methods
01h 18mPython 103: Mmmm... Understanding Python's Memory Model, Mutability, and Methods
27mPython is Weird
28mLoop better: a deeper look at iteration in Python
