mapping None values to ''

imho certo at comeno.it
Sun Jun 18 08:40:28 EDT 2006


micklee74 at hotmail.com ha scritto:
> hi
> i wish to map None or "None" values to "".
> eg
> a = None
> b = None
> c = "None"
> 
> map( <something>  ,  [i for i in [a,b,c] if i in ("None",None) ])
> 
> I can't seem to find a way to put all values to "". Can anyone help?
> thanks
> 

You already filtered [a,b,c] in the comprehension list, so you just have 
to map all its values to "":

map(lambda x:"" , [i for i in [a,b,c] if i in ("None",None) ])



More information about the Python-list mailing list