by Anonymous » 28 Feb 2025, 05:52
Ich versuche, eine statische Methode in Python mit dem Tippen zu type zu fügen. . Der Typ -Hinweis wird jedoch nicht auf das Selbstargument innerhalb der Funktion selbst angewendet. < /P>
Code: Select all
from typing import Self
class Vect:
x: float
y: float
@staticmethod
def angle(v1: Self, v2: Self):
return math.acos(v1 * v2 / v1.magnitude() / v2.magnitude())
Der Code funktioniert, gibt mir jedoch keine Hinweise in der Winkelmethode für Variablen V1 und v2 .
Ich versuche, eine statische Methode in Python mit dem Tippen zu type zu fügen. . Der Typ -Hinweis wird jedoch nicht auf das Selbstargument innerhalb der Funktion selbst angewendet. < /P>
[code]from typing import Self
class Vect:
x: float
y: float
@staticmethod
def angle(v1: Self, v2: Self):
return math.acos(v1 * v2 / v1.magnitude() / v2.magnitude())
[/code]
Der Code funktioniert, gibt mir jedoch keine Hinweise in der Winkelmethode für Variablen V1 und v2 .