3 ms·
Not a huge amount in concrete terms of capability, but the little differences add up in how the languages are used in practice. Python has functions you can ref
by mjfisher 6y ago
Not a huge amount in concrete terms of capability, but the little differences add up in how the languages are used in practice. Python has functions you can refer to and pass around directly (as opposed to Ruby's blocks and procs), and that makes functions that are also generators just a little bit more friction free and more likely to be used. Python also has explicit support for differentiating between generators and regular functions in other parts of it's syntax (e.g. list comprehensions) that tend to make people reach for generators more quickly in Python than other languages.
- nerdponx 6y agoPython's lazy, composable iterators/generators are my #1 favorite Python language feature and I find myself missing it in every other language I use.
- RangerScience 6y agoMost (all?) of Rail's iterators are available as lazy iterators, and I think ditto for core Ruby (it's literally `foo.lazy.each`). Not sure what you mean by "composable" that isn't also the case in Ruby; community standard definitely seems to be that an iterator dot chain doesn't change type (or when it does it's real obvious) making it easy to `.map`, `.select`, etc.