
Rob Cliffe via Python-ideas writes:
Some people clearly need it, viz. those who use a default such as `[]` and then ask on Stack Overflow why they get surprising results.
That's not a "need". That's a "misunderstanding".
You say you don't need late binding, but I would be very surprised if you never found a situation where it was useful. (Starting with avoiding the 'if x==None: x==[]' idiom,
I'm perfectly happy with 'x = [] if x is None else x'. I've been typing that or 'x = x or []' for 25 years; I'm not going to stop now just because new syntax has been added.
In short, if it was available, I think you would find uses for it.
Speak for yourself, not for me, please. For me, this is not even a "nice to have". I am pretty sure I will only use it if I contribute to a project where defaulting to None and testing in the body is ruled out by the style guide. What little doubt I have is that there is something that this is genuinely needed for, which is introspecting the default expression for a late-bound default. In the case of the '<expr> if x is None else x' idiom, you'd have to disassemble the byte code, if you can find it. Here, you'd have the default expression represented in some accessible form. But I have never yet introspected a function's arguments' defaults yet, so I suspect I won't do that for late-bound defaults either.
Come to think of it, I don't think next() is the comparable point, it's when you call the generator function to get an iterable object. IMO, that's a better argument for your point of view.
Not sure what your point is.
It's exactly what I wrote. In using a generator, next() corresponds to the reference to the argument in the body, while calling the generator function to get the generator's iterator corresponds to the evaluation of the default expression to bind to the argument.
(Semi-jocular point) I know you're trying not to be sexist, and yet perhaps in a way you are.
Point taken, even though it's expressed passive-aggressively. The "semi-jocular" just makes it worse, by the way. All you had to do is ask.