[Python] Enforce type hinting in Pytho nclass

Discussão em 'Python' iniciado por Stack, Junho 23, 2025.

  1. Stack

    Stack Membro Participativo

    I need to enforce the type of a class variable, but more importantly, I need to enforce a list with its types. So if I have some code which looks like this:

    class foo:
    def __init__(self, value: list[int]):
    self.value = value


    How can I make sure that value is a list of integers?

    I'm using Python version 3.9.4.

    Continue reading...

Compartilhe esta Página