-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mutable default values shared by class instances #11
Comments
Hi @georgeto, thank you for contributing! 😄 And here I thought I was being clever by making use of mixin classes and fields instead of initializing these attributes in an Anyhow, thank you for spotting and reporting this (and providing me with resources on possible solutions)! I will implement and release a fix soon with version 0.2.1 (along with your PR #10). |
Also: this is example # 9000 in the case for adding a test suite to the project. I have just opened a new issue (#12) for this. Feel free to add to the discussion there if you have additional thoughts and opinions. |
This has been fixed with the 0.2.1 release! |
Some classes have fields with mutable value (e.g. lists), which are assigned a default value (e.g. empty list). If you have several instances of such a class, they each share the default values.
See the following example for illustration:
I assume this was an oversight and not a deliberate design decision. For a detailed explanation and possible solutions, see this section in the Python documentation.
The text was updated successfully, but these errors were encountered: