This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: persistence of attributes with new instance
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.7, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Florian Michaux, serhiy.storchaka
Priority: normal Keywords:

Created on 2018-10-04 13:31 by Florian Michaux, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
buggyclass.py Florian Michaux, 2018-10-04 13:31
Messages (2)
msg327051 - (view) Author: Florian Michaux (Florian Michaux) Date: 2018-10-04 13:31
Hello,

I don't know what's going on.
When using a for loop over multiple same instance creation, i got persistence with instance attributes

Code example in attachement.
msg327052 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-04 13:38
This is how default values work in Python.

See the FAQ question: https://docs.python.org/3/faq/programming.html#why-are-default-values-shared-between-objects
History
Date User Action Args
2022-04-11 14:59:06adminsetgithub: 79073
2018-10-04 13:38:42serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg327052

resolution: not a bug
stage: resolved
2018-10-04 13:31:14Florian Michauxcreate