3 ms·
>I have to constantly remember that to get a length of an array in Python I have to do len(x) rather than x.len() On the other hand, in Python lists, tuples an
by flavio81 9y ago
>I have to constantly remember that to get a length of an array in Python I have to do len(x) rather than x.len()
On the other hand, in Python lists, tuples and arrays are fundamental data types and thus len() is defined as a fundamental built-in function. I think it makes sense.
What i didn't like was when map() and reduce() were moved away from the basic functions.
- bhaak 9y ago> On the other hand, in Python lists, tuples and arrays are fundamental data types and thus len() is defined as a fundamental built-in function. I think it makes sense. But len() is only a fundamental built-in function for fundamental data types and you can implement it on any class by implementing the method __len__(self). For those it doesn't make sense any longer to be able to do len(x).
- flavio81 9y agoI'm afraid you're right...