4 ms·
It's not a bike-shed issue. Surely the other features are great, and Python has lots of powerful abstractions. But once you have closures with a light-weight s
by bad_user 17y ago
It's not a bike-shed issue. Surely the other features are great, and Python has lots of powerful abstractions.
But once you have closures with a light-weight syntax, as Ruby has, the APIs start to look a lot more different.
For example, take this example ...
v = [ x for x in collection if x % 2 == 0 ]
for item in v:
print item
In Ruby the equivalent would be ...
collection.find_all{|x| x % 2 == 0}.each do |item|
puts item
end
Yes, the Python example is elegant, but Ruby doesn't need extra baked-in features like list-comprehensions. It doesn't need a bunch of other features as well, like generators, or generator expressions, or with statements.
There are a lot of PEPs in Python that cover use-cases for Ruby's blocks, trouble is there are still use-cases that aren't covered.
Guido is partially right though ... adding blocks in Python wouldn't be pythonic because blocks wouldn't be orthogonal with lots of other Python features. They should've been added from the start, and now it's kind of late.