So überprüfen Sie, ob sich ein Typ in einer TypeVar befindet oder nichtPython

Python-Programme
Anonymous
 So überprüfen Sie, ob sich ein Typ in einer TypeVar befindet oder nicht

Post by Anonymous »

Ich suche nach einer Möglichkeit zu prüfen (Wahr oder Falsch), ob ein Typ in einer TypeVar vorhanden ist:
from typing import TypeVar
number = TypeVar("number" ,int ,float)

num: number = 3.14

Ich suche so etwas:
print(type(num) in number) # check if "float" is in "number"

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post