On Thu, May 28, 2020 at 10:27:47PM +1200, Greg Ewing wrote: > On 28/05/20 7:31 pm, Chris Angelico wrote: > >Is it an implementation detail that 4 will be used for eggs if it > >isn't passed? > > That feels different to me somehow. I think it has something to do > with declarative vs. procedural stuff. The default value of eggs > being 4 is a static fact, but creating a new Spam object is not.
Would your feeling change if we were talking about a "variables are memory locations" language, where the value 4 has to be copied into the "eggs" memory location? > To my mind, procedural code belongs in the body of the function, > not in the header. An interesting point. I would agree with it, but somehow late-bound default parameters seems to me to be an acceptable exception. But there's certainly a grey area here. Looking over some examples, I can find places where None is being used as a sentinel for what is essentially late binding defaults, but the code required to generate the default value is sufficiently complex that, even if it could be written as a single expression, I wouldn't be really happy about it being put in the function header. On the third hand, no matter how big and hairy a block of code is, if you refactor it into a function, then the late-bound default need never be more complex than a function call. -- Steven _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/3LEDHNNX22AAJIYI4F3ZTLREGTELDJDD/ Code of Conduct: http://python.org/psf/codeofconduct/