I can pick up a Python program and interpret the current standard method without hesitation - it is explicit and there is no ambiguity:
os.path.join(build_dir, os.path.basename(source_file))
Python's dynamic typing makes the first method pretty hard to read when reading:
build_dir / path(source_file).name
Plus it’s not often for line splitting, which causes more confusion. How do I know that these two are not whole? Or swims? You will not get a TypeError at runtime if both end as non-string types.
Finally,
path(build_dir, path(source_file).name)
How is this better than the os.path method?
While they can “simplify” the encoding (that is, make it easier to write), you will run into revelry if someone who is not familiar with alternative modules needs to support the code.
So, I think my answer is: I am not using an alternative path. os.path has everything I need and the interface is not bad.
Matthew iselin
source share