In Python everything is object, but some methods are not called as attributes, but you pass them the instance of object as parameter. For instance:
function len()
expects object - len(str)
seems logical, because it clearly shows that strings are immutable.
But why then str.find()
is called as attribute of str?
I thought that it is because len
excepts more then just one type of object, but this could be solved with polymorphism, right?
Is there any reason for some functions to be called as func(obj)
and some as obj.func()
?