[Python] Why isn't the 'len' function inherited by dictionaries and lists in Python?

Discussão em 'Python' iniciado por Stack, Março 28, 2025.

  1. Stack

    Stack Membro Participativo

    Example:

    a_list = [1, 2, 3]
    a_list.len() # Doesn't work
    len(a_list) # Works


    Python being (very) object-oriented, I don't understand why the 'len' function isn't inherited by the object. Plus I keep trying the wrong solution, since it appears as the logical one to me.

    Continue reading...

Compartilhe esta Página