[issue26458] Is the default value assignment of a function parameter evaluated multiple times if it is Parameter=None

Ezio Melotti report at bugs.python.org
Mon Feb 29 05:30:45 EST 2016


Ezio Melotti added the comment:

This is not a bug, see https://docs.python.org/3.6/faq/programming.html#why-are-default-values-shared-between-objects

In the first case L is evaluated once at compile time.
In the second case L is always set to a new empty list, regardless of what you pass as second argument to f.
In the third case L is set to a new empty list only if you don't pass a second argument (or if you pass None).

----------
nosy: +ezio.melotti
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
type:  -> behavior

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26458>
_______________________________________


More information about the Python-bugs-list mailing list