Y
Hacker News
new
|
ask
|
show
|
jobs
by
Rotareti
2310 days ago
I wish there was a union operator for typing as well to replace `Union[str, int]` with just `[str|int]`.
3 comments
ash
2305 days ago
PEP 604 (draft) proposes this:
def f(list: List[int | str], param: int | None) -> float | str: pass f([1, "abc"], None)
https://www.python.org/dev/peps/pep-0604/
link
LyndsySimon
2310 days ago
Naively, couldn’t your just overload `or` to make that work?
link
ash
2310 days ago
Did you mean `str | int`?
link