mapping None values to ''
Gerard Flanagan
grflanagan at yahoo.co.uk
Sun Jun 18 08:45:23 EDT 2006
More information about the Python-list mailing list
Sun Jun 18 08:45:23 EDT 2006
- Previous message (by thread): mapping None values to ''
- Next message (by thread): mapping None values to ''
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
micklee74 at hotmail.com wrote: > 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 a = [None, 'None', None] def filtre(x): if x is None or x == 'None': return '' else: return x assert map(filtre, a) == ['', '', ''] a = [1, 2, None, 'None', 3, 4] assert map(filtre, a) == [1, 2, '', '', 3, 4]
- Previous message (by thread): mapping None values to ''
- Next message (by thread): mapping None values to ''
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list