[Python] Python terminology dot syntax vs () [duplicate]

Discussão em 'Python' iniciado por Stack, Maio 25, 2025.

  1. Stack

    Stack Membro Participativo

    In my code below, why is it the case that isdigit is written with a dot, it's name, and then parentheses to call it, whereas with length this is written with parentheses surrounding zip_code?

    Are they not both things acting on the object zip_code?

    def is_valid_zip(zip_code):
    """Returns whether the input string is a valid (5 digit) zip code
    """
    return zip_code.isdigit() and len(zip_code) == 5


    i.e. why is is not...

    isdigit(zip_code) and zip_code.len()


    What terminology do I need here so I can research the difference between what these things are?

    Continue reading...

Compartilhe esta Página