[Python-ideas] Default arguments in Python - the return - running out of ideas but...
Pascal Chambon
chambon.pascal at wanadoo.fr
Tue May 19 22:31:00 CEST 2009
CTO a écrit :
> On May 18, 5:17 pm, Chris Rebert <pyid... at rebertia.com> wrote:
>
>>
>> The BDFL has condemned introducing new assignment operators. Seehttp://www.python.org/dev/peps/pep-3099/:
>>
>> "There will be no alternative binding operators such as :=."
>>
>> Cheers,
>> Chris
>>
That's weird, in the archives quoted, I've found no exchange around the
pros and cons of alternative binding operators, except the BDFL's "Brrh".
---> http://mail.python.org/pipermail/python-dev/2006-July/066995.html
I guess that the operators rejected there mostly concerned the
differentiation between binding and rebinding, although I couldnt be sure.
Without new keyword or operator, a good looking solution for dynamic
defaults is unlikely to appear, imo.
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: [])" ?
Regards,
Pascal
More information about the Python-ideas
mailing list