Greg Falcon a écrit :
def foo(): def myfunc(a, b, c = (yield )): pass
already has a meaning in Python. Under your proposal,
Aowh... I didn't even think this was legal, but indeed this works... so it's obviously dead for "yield".
Anyhow, since you've decided you want add a new kind of default argument spelled differently than the standard one, I have to ask what this buys you beyond
def foo(): def myfunc(a, b, c = None): if c is not None: # or a setinel c = 
Sure, it takes two more lines of code to write this (three if you want to use an object() instance as your sentinel to allow None being passed in), but does not require a new bit of language syntax for every Python programmer to learn...
Well, not only do we have to write more code, but we lose in self-documentation I guess (I'd rather have the default appearing in the signature than in the function code - pydoc and stuffs won't notice it), and I find slightly disappointing the principle of a "sentinel", i.e "I would have wanted to do something there but I can't so I'll do it farther, take that in the meantime".
There's the suggestion that Carl Johnson gave:
def myfunc(a, b, c else ): pass
def myfunc(a, b, c def ): pass
where 'def' stands for 'default' (or "defaults to").
Those phrases could do it, I'm just worryied about the fact that semantically, they make (to me) no difference with "c = ". None of those ways looks more "dynamic" than teh other, so it might be hard to explain why "=" means compiel time, and "def" means runtime.
I must admit I'm totally out of ideas then.