@@ -493,14 +493,15 @@ case the parameter's default value is substituted. If a parameter has a default
493493value, all following parameters up until the "``* ``" must also have a default
494494value --- this is a syntactic restriction that is not expressed by the grammar.
495495
496- **Default parameter values are evaluated when the function definition is
497- executed. ** This means that the expression is evaluated once, when the function
498- is defined, and that the same "pre-computed" value is used for each call. This
499- is especially important to understand when a default parameter is a mutable
500- object, such as a list or a dictionary: if the function modifies the object
501- (e.g. by appending an item to a list), the default value is in effect modified.
502- This is generally not what was intended. A way around this is to use ``None ``
503- as the default, and explicitly test for it in the body of the function, e.g.::
496+ **Default parameter values are evaluated from left to right when the function
497+ definition is executed. ** This means that the expression is evaluated once, when
498+ the function is defined, and that the same "pre-computed" value is used for each
499+ call. This is especially important to understand when a default parameter is a
500+ mutable object, such as a list or a dictionary: if the function modifies the
501+ object (e.g. by appending an item to a list), the default value is in effect
502+ modified. This is generally not what was intended. A way around this is to use
503+ ``None `` as the default, and explicitly test for it in the body of the function,
504+ e.g.::
504505
505506 def whats_on_the_telly(penguin=None):
506507 if penguin is None:
0 commit comments