[issue39556] Different objects of the same class references the same dictionary

Ammar Askar report at bugs.python.org
Wed Feb 5 01:55:56 EST 2020


Ammar Askar <ammar at ammaraskar.com> added the comment:

This is a common mistake, you'll find the FAQ entry for it here: https://docs.python.org/3/faq/programming.html#why-are-default-values-shared-between-objects

It's not necessarily a "feature" but default values in functions are only created once, when the function is defined. Subsequent calls will refer to that same initially created object.

----------
nosy: +ammar2
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39556>
_______________________________________


More information about the Python-bugs-list mailing list