File system path annotations
Peter Slížik
peter.slizik at gmail.com
Mon Jun 19 04:43:38 EDT 2023
Hello,
what is the preferred way of annotating file system paths?
This StackOverflow answer <https://stackoverflow.com/a/58541858/1062139>
(and a few others) recommend using the
str | os.PathLike
union.
However, byte arrays can be used as paths too, and including them
would make the annotation quite long.
I also believe that str confirms to the PathLike definition. Please,
correct me if I'm wrong.
And finally - using paths in Python programs is so common, that one
would expect to have a special type (or type alias) in typing. Am I
missing something?
My apologies if I'm asking the obvious, but after some googling I came
to the conclusion that information on this topic is surprisingly
limited to a few StackOverflow questions.
Best regards,
Peter
More information about the Python-list
mailing list