3 ms·
Map and filter are looked down upon by some Python devs because they prefer list comprehensions. If you don't need the laziness (in Python 3 only), you probably
by 3pt14159 11y ago
Map and filter are looked down upon by some Python devs because they prefer list comprehensions. If you don't need the laziness (in Python 3 only), you probably shouldn't use them because some don't consider them idiomatic. See this for more information:
http://stackoverflow.com/a/6407222/384700 http://stackoverflow.com/a/6407222/384700
- ggchappell 11y ago> If you don't need the laziness (in Python 3 only), you probably shouldn't use them .... And if you do need the laziness, then you can use generator comprehensions.
- hoov 11y agoYeah, map and filter not really idiomatic; you're almost always better served by a list/generator comprehension. Even Guido has regrets about map/filter/reduce: http://legacy.python.org/doc/essays/ppt/regrets/PythonRegrets.ppt http://legacy.python.org/doc/essays/ppt/regrets/PythonRegret....
- 699 11y agoThat's a bummer, actually. "filter(thing, None)" is far prettier than "[thing for thing in things if thing is not None]" :(