Re: Default parameters
Terry Reedy wrote:[color=blue]
>
>
>
> "Stian S?iland" <stain@stud.ntn u.no> wrote in
> message
> news:slrnbtvte6 .tnk.stain@ozel ot.stud.ntnu.no ...[color=green]
>> When is this issue going to be resolved? Enough[/color]
> newbie-pythoners have[color=green]
>> made this mistake now.[/color]
>
> I am puzzled as to why. When I learned Python, I
> read something to the effect that default value
> expressions are evaluated at definition time. I
> understood that the resulting objects were saved
> for later use (parameter binding) when needed (as
> default for value not given). I believed this and
> that was that.[/color]
I am puzzled as to why you're puzzled. Not everyone who reads the
manual pays attention to the time of evaluation explanation, if the
manual they're using even covers. Not everyone stops and says, "Oh my
God, I don't know whether this is evaluated when the function is
defined or called. I better find out." (And of course, not everyone
reads the manual.)
It seems that most people who haven't thought about time of evaluation
tend to expect it to be evaluated when the function is called; I know
I would expect this. (I think I even made the mistake.)
--
CARL BANKS http://www.aerojockey.com/software
"If you believe in yourself, drink your school, stay on drugs, and
don't do milk, you can get work."
-- Parody of Mr. T from a Robert Smigel Cartoon
Terry Reedy wrote:[color=blue]
>
>
>
> "Stian S?iland" <stain@stud.ntn u.no> wrote in
> message
> news:slrnbtvte6 .tnk.stain@ozel ot.stud.ntnu.no ...[color=green]
>> When is this issue going to be resolved? Enough[/color]
> newbie-pythoners have[color=green]
>> made this mistake now.[/color]
>
> I am puzzled as to why. When I learned Python, I
> read something to the effect that default value
> expressions are evaluated at definition time. I
> understood that the resulting objects were saved
> for later use (parameter binding) when needed (as
> default for value not given). I believed this and
> that was that.[/color]
I am puzzled as to why you're puzzled. Not everyone who reads the
manual pays attention to the time of evaluation explanation, if the
manual they're using even covers. Not everyone stops and says, "Oh my
God, I don't know whether this is evaluated when the function is
defined or called. I better find out." (And of course, not everyone
reads the manual.)
It seems that most people who haven't thought about time of evaluation
tend to expect it to be evaluated when the function is called; I know
I would expect this. (I think I even made the mistake.)
--
CARL BANKS http://www.aerojockey.com/software
"If you believe in yourself, drink your school, stay on drugs, and
don't do milk, you can get work."
-- Parody of Mr. T from a Robert Smigel Cartoon
Comment