Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

> Not so obvious in [ x.y for x in X ]

Yes it is - that's always a method call: http://docs.python.org/reference/datamodel.html#invoking-des...

The problem is that you're unclear whether it's a mutating method or not, as well as whether it's an expensive operation. But that can be solved a number of ways - immutability and lazy evaluation would be one approach, though unfortunately neither Python nor Ruby enforces immutability, and both use absurdly eager evaluation.

(Regarding that last point, try doing [x.y() for x in foo][0] and you'll see that y is called for every x!)



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: