csv blank fields

Mag Gam magawake at gmail.com
Tue Jun 30 00:47:21 EDT 2009


Thankyou!



On Tue, Jun 30, 2009 at 12:17 AM, Chris Rebert<clp2 at rebertia.com> wrote:
> On Mon, Jun 29, 2009 at 8:47 PM, Lawrence
> D'Oliveiro<ldo at geek-central.gen.new_zealand> wrote:
>> In message <mailman.2218.1246122370.8015.python-list at python.org>, MRAB
>> wrote:
>>
>>>      row = [r or "NULL" for r in row]
>>
>> I know that, in this particular case, all the elements of row are strings,
>> and the only string that is equivalent to False is the empty string, but
>> still
>>
>>    row = [[r, "NULL"][r == ""] for r in row]
>
> While I do find the use of booleans as integers interesting, I think
> the ternary operator would be clearer:
>
> row = [("NULL" if r == "" else r) for r in row]
>
> Cheers,
> Chris
> --
> http://blog.rebertia.com
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list