SH | Diensttagebuch

In the middle of the desert you can say anything you want

02 Nov 2021

211102-0111 python defining own types for typing

After writing whatever: str or Path or whataver: Union[str, Path] for the N-th time I googled how to do this better. Well, 1

from typing import Union
from pathlib import Path

pathlike = Union[str, Path]

whatever: pathlike = some_function()

def f_paths(path_one: pathlike):

  1. What is the correct way in python to annotate a path with type hints? - Stack Overflow ↩︎

Nel mezzo del deserto posso dire tutto quello che voglio.