One example of many. In Ruby, you can merge hashes (JavaScript "objects") by doing `x.merge(y)`. That's been in forever. It's a simple thing. You call merge; done.
Python trends towards top level functions for things that Ruby puts on Enumerable though, right? e.g. it's `len(list)` not `list.len()`
-
-
Yes, but there aren't that many, and they just call those weird underscore methods. E.g., len(list) actually does list.__len__(); iter(list) does list.__iter__(); etc. It didn't age well IMO, but it did make map(len, xs) look nice without the need for something like &: syntax.
-
Gotcha. Yeah, `&:` really seems like more of an artifact of methods being separate from properties. I've definitely wanted a better way to write the python equivalent of `map(this.some_func, xs)` in Ruby than `http://xs.map (&method(:some_func))`
- 5 more replies
New conversation -
-
-
You can trace a lot of weird stuff like this back to Python core (and ultimately Guido) avoiding new syntax.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.