4 ms·
One thing I don't like about Python libraries, from the top of my head: That there is a distinction between functions and methods, e.g. between nansum(a) and a.
by jkabrg 9y ago
One thing I don't like about Python libraries, from the top of my head: That there is a distinction between functions and methods, e.g. between nansum(a) and a.sum() where a is a numpy array. The distinction is illogical and just has to be memorized, much like the difference between different categories of verbs in French.
In contrast, R uses an exotic form of object oriented programming called multimethods, which doesn't make a distinction between object.method() and method(object). And if you like chaining methods together like object.method1().method2().method3(), then you can do that in R using the piping operator from the Dplyr package: object %>% method1() %>% method2() %>% method3(), which is rightly equivalent to method3(method2(method1(object)))
- goatlover 9y agoThe reason there is a distinction in Python between functions and methods is because Python supports multiple paradigms. It doesn't force the programmer into using OOP. Sometimes you want a function that doesn't belong to some kind of data type, and sometimes you want to create a new type of data and define methods that work only for it.
- singingfish 9y agoYou make it sound like perl (only perl is more flexible - both its major strength and weakness)