Is arr.__len__() the preferred way to get the length of an array in Python?
The same works for tuples: And strings, which are really just arrays of characters: It was intentionally done this way so that lists, tuples and other container types or iterables didn’t all need to explicitly implement a public .length() method, instead you can just check the len() of anything that implements the ‘magic’ __len__() method. Sure, this may seem redundant, but length checking … Read more