Help cleaning up some code

andrew cooke andrew at
Sat Mar 7 14:05:18 CET 2009

ah, yes, i didn't see that clearly.  in this case it might be better to have:

def copy(src, dst, name, null):
 value = src[name]
 dst[name] = null if value is None else value

and then make it explicit in both cases:

copy(row, ad, name, null=None)
copy(row, ad, name, null='None')


Paul Rubin wrote:
> "andrew cooke" <andrew at> writes:
>> def copy(src, dst, name, quote_none=False):
>>   value = src[name]
>>   dst[name] = 'None' if quote_none and value is None else value
> def copy(src, dst, name, default=None):
>   value = src[name]
>   dst[name] = value if value is not None else default
>>     copy(row, ad, name, quote_none=True)
>   copy(row, ad, name, default='None')
> --

More information about the Python-list mailing list