Originally Posted by Chris++
There is one right way in Python, the so called "pythonic" code has been proven to be more efficient, reducing the amount of function calls and in many cases reducing the memory footprint.
You may argue that this is minimal and irrelevant with today's hardware, and while I will agree on a trivial example as this one, on a large scale project it will add up.
As a final argument for my statement... and excerpt from the Zen of Python (a text that describes Python's philosophy) "There should be one-- and preferably only one --obvious way to do it.".
Bizarre. I mean, I don't understand why functions such as 'filter' even exist in that case. What's the point of having these functions if they're not really supposed to be used? I guess it doesn't make sense to me.
This is basically the exact instance I would see anyone using 'filter', I'm having a hard time figuring out its utility if you're supposed to iterate using a list comprehension. But I guess that's just Python. I've heard the term "pythonic" several times before, but I always assumed that was a way to express how idiomatic code is, not how "correct" it is. Huh.
Edit: As an aside, the most obvious way for me to tackle this problem was to use 'filter', as I'm coming from a strong functional programming background using Haskell, and in Haskell, we use 'filter' a lot!Edited by 5outh - 8/20/12 at 12:57pm