On 28.05.20 17:44, Christopher Barker wrote:

On Thu, May 28, 2020 at 3:50 AM Alex Hall <alex.moj...@gmail.com
<mailto:alex.moj...@gmail.com>> wrote:

    On Thu, May 28, 2020 at 12:38 PM Greg Ewing
    <greg.ew...@canterbury.ac.nz <mailto:greg.ew...@canterbury.ac.nz>>
    wrote:


        But I'm having trouble thinking of one. I can't remember ever
        writing a function with a default argument value that *has* to
        be mutable and *has* to have a new one created on each call
        *unless* the caller provided one.


Actually, we need to one further: a default argument value that *has* to
be mutable and *has* to have a new one created on each call
*unless* the caller provided one ...

and *has* to treat None as valid value.

That's the scenario where you'd need to create a sentinel object to take
the role of None. However late binding of defaults won't save you from this.

The biggest advantage, as far as I understood, is that you can specify a
default (expression) as part of the function header and hence provide a
meaningful example value to the users rather than just None.

_______________________________________________
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/P3XDOGYMUJQQWKNKL5O3IZLRFGJYMLNI/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to