On Thu, May 28, 2020 at 9:01 AM Greg Ewing <greg.ew...@canterbury.ac.nz> wrote:
> On 28/05/20 12:38 pm, Rob Cliffe wrote: > > why not go > > further (as the OP suggested as far as I recall) > > and allow the more concise > > > > def order(eggs = 4, spam ?= Spam()): > > etc. > > That clutters up the header with things that are not part of > the function's signature. All the caller needs to know is that > the spam argument is optional. > I'm very surprised by this sentiment. The signature says that the default value for spam is an instance of Spam, namely one constructed with no arguments. That's useful information! I wrote a long post about this here: https://mail.python.org/archives/list/python-ideas@python.org/message/6TGESU6AQSDFLIV2UBHAB4E2NVVREVPA/ - do you have any thoughts on that? (side note - I'm just seeing now how mailman handles inline images, which is very disappointing) The fact that a new Spam object > is created on each call if he doesn't supply one is an > implementation detail. > I don't think it is - knowing that the default isn't shared across calls could be quite important. But aside from that, there's only one character (`?`) which represents that detail, and that's an acceptable amount of 'clutter'. The rest (`=Spam()`) is just saying what the default value is, and we don't usually consider that clutter.
_______________________________________________ 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/A3NHMQLN7LDNMCCMT7XZ3DT4SQZBOQTG/ Code of Conduct: http://python.org/psf/codeofconduct/