.. _dangerous-default-value:

dangerous-default-value / W0102
===============================

**Message emitted:**

Dangerous default value %s as argument

**Description:**

*Used when a mutable value as list or dictionary is detected in a default value for an argument.*

**Problematic code:**

.. literalinclude:: /data/messages/d/dangerous-default-value/bad.py
   :language: python

**Correct code:**

.. literalinclude:: /data/messages/d/dangerous-default-value/good.py
   :language: python

**Additional details:**

With a mutable default value, with each call the default value is modified, i.e.:

.. code-block:: python

    whats_on_the_telly() # ["property of the zoo"]
    whats_on_the_telly() # ["property of the zoo", "property of the zoo"]
    whats_on_the_telly() # ["property of the zoo", "property of the zoo", "property of the zoo"]


Created by the `basic <https://github.com/PyCQA/pylint/blob/main/pylint/checkers/base/basic_checker.py>`__ checker.