I know that python has a len()
function that is used to determine the size of a string, but I was wondering why it’s not a method of the string object.
Update
Ok, I realized I was embarrassingly mistaken. __len__()
is actually a method of a string object. It just seems weird to see object oriented code in Python using the len function on string objects. Furthermore, it’s also weird to see __len__
as the name instead of just len.