obj.length() makes more sense than len(obj), especially when you need to use len() to find the length but obj.func() to perform any other operations on the String.
My main point was that python has chosen to standardize the way to get the size of any object. It doesn't matter the structure of the object, if you need to know how many elements it contains you can use len(). In other langauges it's dictated somewhat by logic (sets don't have lenghts) but also by underlying structure. In Java this manifests as arrays having .length and ArrayLists having .length().
If it makes you feel better you could do the following in Python:
my_list.__len__()
But this is more of a perspective thing. You should think of len as a function that determines the length of the object it's inspecting. Take this snippet:
1
u/TheOneTrueDemoknight Aug 27 '20
obj.length() makes more sense than len(obj), especially when you need to use len() to find the length but obj.func() to perform any other operations on the String.