News for hackers. Stuff that matters.
Re:Ask HN: Why Python over Ruby? by cbr on Wednesday July 01, 2009 @07:08PM (#683534)
You can do ", ".join(x) on any x that you can do "for y in x" on. If join were a method of the list (or sequence, or iterator, ...) then it would need to be defined over and over again.
Re:Ask HN: Why Python over Ruby? by earthboundkid on Thursday July 02, 2009 @06:19AM (#684123)
Or it would have to inherit the method from a common iterator class. Which gets to the heart of the Ruby/Python thing: In Python inheritance just isn't as stressed, since people prefer duck-typing to isinstance. On the other hand, since you can reopen classes in Ruby, it's not as crazy to use the modification of a common base class as a means of making a method work with a wide variety of object types.