Removing None objects from a sequence

Vito De Tullio zak.mc.kraken at libero.it
Fri Dec 12 10:34:42 EST 2008


Filip Gruszczyński wrote:

> I checked itertools, but the only thing that
> seemed ok, was ifilter - this requires seperate function though, so
> doesn't seem too short. 

is this too much long?

>>> from itertools import ifilter
>>> for element in ifilter(lambda x: x is not None, [0,1,2,None,3,None,4]):
...     print element
...
0
1
2
3
4
>>>   

-- 
By ZeD




More information about the Python-list mailing list