question of style

Lie Ryan lie.1296 at gmail.com
Fri Jul 3 04:06:18 EDT 2009


Paul Rubin wrote:
> Lie Ryan <lie.1296 at gmail.com> writes:
>> I guess in python, None as the missing datum idiom is still quite prevalent:
> 
> Well, sometimes there is no way around it, but:
> 
>> def cat_list(a=None, b=None):
>>     # poor man's list concatenation
>>     if a is None and b is None: return []
>>     if a is None: return b
>>     if b is None: return a
>>     return a + b
> 
> def cat_list(a=[], b=[]):
>     return a + b

Being super contrived is why I tagged it as poor man's concat.
Generally, there will be a processing:

...
    if b is None: return a
    # processing here
    return retlist
...

and it will not be about concatenating two lists, but something more
complex. But I thought that was unnecessary since I just want to mention
about the None argument idiom.



More information about the Python-list mailing list