[issue44216] Bug in class method with optional parameter

Steven D'Aprano report at bugs.python.org
Sun May 23 11:39:17 EDT 2021


Steven D'Aprano <steve+python at pearwood.info> added the comment:

This is not a bug, this is working as the language is designed, and the behaviour occurs for all functions, not just class methods. Default values are only evaluated once, when the function is defined, not every time the function is called.

This is even described in the FAQs:

https://docs.python.org/3/faq/programming.html#id13

----------
nosy: +steven.daprano
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

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


More information about the Python-bugs-list mailing list