Monty @ The Python Coding Place @thepythoncodingplace.com · Feb 24

You've seen the mutable default value pitfall when defining functions… …but let's open the function black box to see what's really happening. Let's start with this function (Don't Do This in Real Code!) /1

2 likes 1 replies

?

Replies

Monty @ The Python Coding Place · Feb 24

Functions are objects. When you define a function you create a `function` object… …and one of this `function` object's attributes is `.__defaults__`, which contains any default values defined in the function signature. You can see there's the empty list there /2