Keyword arguments - strange behaviour?
Steve Holden
steve at holdenweb.com
Tue Dec 21 10:27:48 EST 2004
harold fellermann wrote:
> Hi,
>
> I cannot see any strange behavior. this code works exacly as you and I
> suspect:
>
> >>> def otherfunction(x) :
> .... return x
> ....
> >>> def function(arg=otherfunction(5)) :
> .... return arg
> ....
> >>> function(3)
> 3
> >>> function()
> 5
>
> Or is this not what you excepted?
>
Channelling the effbot, I think he was asking what namespace context you
expected the expression "arg=otherfunction(x)" to be evaluated in when
it's used at the time of a function call to dynamically create a new
default value for arg.
regards
Steve
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/
Holden Web LLC +1 703 861 4237 +1 800 494 3119
More information about the Python-list
mailing list