[Python-ideas] Default arguments in Python - the return - running out of ideas but...

Oleg Broytmann phd at phd.pp.ru
Tue May 19 22:34:09 CEST 2009


On Tue, May 19, 2009 at 10:31:00PM +0200, Pascal Chambon wrote:
> I could content myself of the proposed solution :
> @dynamic
> def func (a, b = lambda : []):
>    pass
> But I just dislike the fact that the "dynamic" applies to all the  
> defaults, even those which weren't supposed to be dynamic (and writing  
> "lambda : lambda : []") doesn't look good).
> Would there be any way of separating "to-be-called" lambdas from normal  
> ones ? Except with a syntax like "b = dyn(lambda: [])" ?

@dynamic('b')
def func (a, b = lambda : []):
    pass

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.



More information about the Python-ideas mailing list