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.
Created on 2008年04月06日 07:31 by warnhold, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| class_with_listparamdefault.py | warnhold, 2008年04月06日 07:31 | |||
| Messages (2) | |||
|---|---|---|---|
| msg65024 - (view) | Author: Werner Arnhold (warnhold) | Date: 2008年04月06日 07:31 | |
I don't know if it is a bug or a feature but the result seems to be wrong for me: A constructor argument remembers its values from the last call |
|||
| msg65025 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2008年04月06日 08:30 | |
Yes, this is expected. Default values are only evaluated once, at function creation time. If you need to have a mutable default argument that is assigned to something and changed, use something like this: def f(arg=None): if arg is None: arg = [] ... |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:33 | admin | set | github: 46813 |
| 2008年04月06日 08:30:51 | georg.brandl | set | status: open -> closed resolution: wont fix messages: + msg65025 nosy: + georg.brandl |
| 2008年04月06日 07:31:58 | warnhold | create | |