Hello,

I finally had a look at the pathlib module. (Should have done it long ago,
but anyway...). Having in mind the replies from my older thread (File
system path annotations), what is the best way to support all possible path
types?

def doit(path: str | bytes | os.PathLike):
match path:
case str() as path:
print("string")

case bytes() as path:
print("bytes")

case os.PathLike() as path:
print("os.PathLike")

Should I branch on the individual types or is there a more elegant way?

Peter
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to