mutable default parameter problem [Prothon]

Pierre-Frédéric Caillaud peufeu at free.fr
Fri Jun 18 14:23:26 CEST 2004


	Nice !
	I wish Python had this, too.

	Also, re-evaluating each time will allow one to use a global variable  
whose value could change as a default parameter. Which looke suspicious.  
Or something like that, which is GOOD :

	class youpi( object ):
		def mymethod( self, a=self.a, b=self.b ):
			...


> Pierre-Frédéric Caillaud wrote:
>
>>> 2) Evaluate the default expression once at each call time when the
>>> default
>>> value is needed.  The default expression would be evaluated in the
>>> context
>>> of the function definition (like a closure).
>>
>>
>> I like Choice 2 because I've always wanted to do the following :
>>
>> def func( x, y=2*x ):
>
> It looks like you will get your wish.  The voting has been pretty much
> unanimous for option 2.
>
>



-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/



More information about the Python-list mailing list