mapping None values to ''

Max Erickson maxerickson at gmail.com
Sun Jun 18 19:42:50 EDT 2006


"Roberto Bonvallet" <rbonvall at gmail.com> wrote:
> You don't need map when using list comprehensions:
> 
>     ["" for i in [a, b, c] if i in ("None", None)]
> 

That loses list elements that aren't in the tests:

>>> a=7
>>> b="None"
>>> c=None
>>> ["" for i in [a,b,c] if i in ("None",None)]
['', '']
>>> 

max




More information about the Python-list mailing list