Which is more pythonic?

alex23 wuwei23 at gmail.com
Thu Dec 3 22:20:23 EST 2009


Filip Gruszczyński <grusz... at gmail.com> wrote:
> I guess map version would be fastest and explicit for is the slowest
> version. However, the first, most obvious way seems most clear to me
> and I don't have to care about speed with adding elements to combo
> box. Still, it's two lines instead of one, so maybe it's not the best.
> So, which one is?

Both map and the listcomp create & modify a list, which seems kind of
odd to do if you're just throwing the list away afterward.

What's more important than a low line count is clarity of intent. The
for-loop makes it clear to me that it's the action against each item
that's important, not the resulting list of processed items.



More information about the Python-list mailing list