[Python] How to write a static python getitem method?

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

  1. Stack

    Stack Membro Participativo

    What do I need to change to make this work?

    class A:
    @staticmethod
    def __getitem__(val):
    return "It works"

    print A[0]


    Note that I am calling the __getitem__ method on the type A.

    Continue reading...

Compartilhe esta Página