|
|
|
|
|
by kazinator
2248 days ago
|
|
> the default value does not have to be a literal value The default isn't a literal value when it is [], by the way. If [] were a literal, then this would not be safe or correct: def fun():
local = []
local.append(3)
The fact is that whenever [] is evaluated, it produces a fresh list each time. It's a constructor for an empty list, exactly like set() for an empty set. It just has slicker syntactic sugar.Python just calls that a literal because it looks like one. Looking is being, in Python. Except for all the pitfalls. |
|