[Python-ideas] Minimal built-ins (+ tiny doc suggestion)
Antoine Pitrou
solipsis at pitrou.net
Fri May 25 11:52:06 CEST 2012
On Fri, 25 May 2012 19:09:29 +1000
Steven D'Aprano <steve at pearwood.info> wrote:
> Nick Coghlan wrote:
>
> > I'd personally agree with filter() moving, but "map(str, seq)" still
> > beats "(str(x) for x in seq)" by a substantial margin for me when it
> > comes to quickly and cleanly encapsulating a common idiom such that it
> > is easier both to read *and* write.
>
> filter(None, seq)
> [obj for obj in seq if obj]
>
> I think the version with filter is *much* better than the second.
Only if you remember what the special value None does when passed to
filter. The cognitive burden is higher.
That said, the idea of moving filter() and map() away won't fly before
at least Python 4.
Regatds
Antoine.
More information about the Python-ideas
mailing list