Showing posts with label URL. Show all posts
Showing posts with label URL. Show all posts

Thursday, March 31, 2016

What is a path?

Wisecracker.

pathlib is a provisional stdlib module. However, as the current threads (here, here, here and here) on python-ideas show, it is not as easy to work with as originally intended. Once you have a Path object, it's quite easy to use what Path offers which is a lot.

One big problem, though, is the interaction of Path objects with existing stdlib functions. Most of the later are string-consuming functions whereas the former are no strings at all. As far as I can see, this is one reason why pathlib lacks broader adoption and many agree. This situation leads to the following possible resolutions:
  1. make Path objects compatible with strings (basically make them inherit from strings)
  2. make existing stdlib functions accept Path objects (basically make them accept both and convert if needed)
  3. do both but that seems superfluous
Solution 2 would also affect third-party libraries as noted here.

In order to decide appropriately, it becomes necessary to answer the following question: