[Python-ideas] Syntax for late-binding of arguments [was: Default arguments ...]

Jim Jewett jimjjewett at gmail.com
Fri May 15 16:14:24 CEST 2009


On 5/15/09, Steven D'Aprano <steve at pearwood.info> wrote:
> On Fri, 15 May 2009 08:26:30 pm Nick Coghlan wrote:
>> Steven D'Aprano wrote:
>> > ...inside the parameter list, &x would mean to delay evaluation ...

>> Marking the parameter name strikes me as wrong anyway - it's only the
>> evaluation of the default argument which is special, not the
>> parameter itself.

> But it is the parameter that is special. The default object itself is
> not. Consider the function definition:

> def f(x=[], &y=[]):

> (or any other syntax you prefer). The empty list you get as the default
> value for x is exactly the same as the empty list you get in y, in
> every way except for identity.

Logically, you're correct.  But I think the ('&' ==> addressof) meme
may have already grown too strong.  What it suggests to me is that
normally you *would* create a new list, but the ampersand says not to
in just this rare case.

-jJ



More information about the Python-ideas mailing list