---
title: "Never Use [ ] as a Default Argument in Python..."
url: https://daily.dev/posts/never-use-as-a-default-argument-in-python--kbiu5bw3s
source_url: https://www.youtube.com/watch?v=O0-XRXdMKBw
type: video:youtube
source: "NeuralNine"
published: 2026-05-27T14:53:19.392Z
updated: 2026-05-27T14:53:38.484Z
tags: ["python"]
reading_time: 8
upvotes: 1
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Never Use [ ] as a Default Argument in Python...

**[NeuralNine](https://daily.dev/sources/neuralnine)** · 8 min read · 1 upvotes · 0 comments

## Summary

Using mutable objects like lists, dictionaries, or sets as default arguments in Python functions is a common beginner pitfall. The mutable object is initialized once at function definition time, not on each call, meaning all calls share the same object. This leads to unexpected state accumulation across calls. The correct fix is to use None as the default and initialize the mutable object inside the function body, and optionally use .copy() when passing an existing mutable object to avoid mutation side effects.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=O0-XRXdMKBw>

---

Tags: [#python](https://daily.dev/tags/python)

[View this post on daily.dev](https://daily.dev/posts/never-use-as-a-default-argument-in-python--kbiu5bw3s)
