Code: Select all
def f1(a: int, **other_args):
...
def f2(a: int, b: str, c: dict):
...
def f3(a: int, b: tuple[str], **other_args):
...
Jetzt möchte ich sie in einer Liste speichern: < /p>
Code: Select all
l: list[?] = [f1, f2, f3]
< /code>
Ich weiß, dass ich so etwas wie < /p>
machen kannimport typing
param_spec = typing.ParamSpec('param_spec')
l: list[typing.Callable[typing.Concatenate[int, param_spec], typing.Any]] = [f1, f2, f3]
< /code>
Aber es würde bedeuten < /p>
l: list[typing.Callable[typing.Concatenate[int, ...], typing.Any]] = [f1, f2, f3]
Code: Select all
l: list[typing.Callable[[int, ...], typing.Any]] = [f1, f2, f3]
< Br /> Gibt es einen Typ, der diese Art von Funktionen beschreibt? Wie kann ich das tun?
Danke für deine Hilfe!