Mutable default arguments in Python

Опубликовано: 11 July 2026
на канале: Python Morsels
516
27

In Python, default argument values are defined only one time (when a function is defined).

Article at https://pym.dev/mutable-default-argum...

More #Python screencasts at https://pym.dev/screencasts/

00:00 Functions can have default values
00:20 A shared default value
00:49 Default values are only evaluated once
01:14 Mutable default arguments can be trouble
01:40 Shared argument values are the real problem
02:04 Avoiding shared argument issues by copying
02:51 Avoiding mutable default values entirely
03:31 Be careful with Python's default argument values