On Thursday, May 28, 2020, at 06:47 -0400, Alex Hall wrote:

> On Thu, May 28, 2020 at 12:38 PM Greg Ewing <greg.ew...@canterbury.ac.nz>
> wrote:
>
>> On 28/05/20 8:57 pm, Steven D'Aprano wrote:
>> > The default value used by a parameter is certainly important, and one of
>> > the most common reasons I call `help(func)` is to see what the default
>> > values are. They should be in the signature, and it is an annoyance when
>> > all the signature shows is that it is None, and then I have to trawl
>> > through screenfuls of docs, or search the web, to find out what the
>> > actual default is.
>>
>> I think we need a real example to be able to talk about this
>> meaningfully.
>>
>> 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.
>>
>> Anyone else have one?
>>
>
> I think the most common cases are where the default is an empty list or
> dict ...

That's what I thought of:  an accumulator in a reduce or fold function.
The default is an empty list that has to be recreated at every function
call, but the caller can supply their own empty container that supports
some sort of extend or add functionality.
_______________________________________________
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/UXPPJBSLTDE3FJYDDVIBV7L7L6DS5AOC/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to