On 2019-07-29, Richard Damon <rich...@damon-family.org> wrote:
> On 7/28/19 7:46 PM, Michael Torrie wrote:

>> Yet the recommended solution to the problem of wanting a default
>> argument of an empty list is something like this:
>>
>> def foo(bar=False);
>>     if bar is False:
>>         bar = []
>>
>>     ....
>
> I thought the recommended value was None, not False (so you don't need
> to ask why not True). I suppose if None is a valid value for the input
> you would need something else, and False is one possibility.

Yes 'None' is definitely the normal idiom, and everybody will know
what you're doing.  If you use False, people are going to be confused.

def foo(bar=None)
   if bar is None
       bar = []
   ...




-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to