Nov-16-2017, 04:47 PM
Thanks, @DeaD_EyE. Your explanation is very clear. You put on paper my suspicions about the mechanics of pathlib comparision.
However, I am not saying that there is anything buggy on pathlib. I am asking whether this should be the expected behaviour of comparing pathlib.Paths or not.
In my opinion, pathlib.Paths should be compared as a list of the string filenames to which they referred, not as a list of their parts (as you have clarified).
In python terms, for me this expression should be True:
Among other things, for example, if filenames and pathlib.Paths are sorted in the same way, you can use a sorted list of sorted filenames to create a sorted list of pathlib.Paths without the need of re-sorting (do mathematicians call this isomorphism, a property of ordered bijection? --my school days were long ago).
I think that would be a great feature since pathlib.Paths and string filenames are used in many contexts as if they were the same thing (os and os.path modules, for instance).
What do you think?
However, I am not saying that there is anything buggy on pathlib. I am asking whether this should be the expected behaviour of comparing pathlib.Paths or not.
In my opinion, pathlib.Paths should be compared as a list of the string filenames to which they referred, not as a list of their parts (as you have clarified).
In python terms, for me this expression should be True:
sorted([str(path) for path in list_of_pathlib_paths]) == sorted(list_of_pathlib_paths)Do you think that this would be a desirable result or not?
Among other things, for example, if filenames and pathlib.Paths are sorted in the same way, you can use a sorted list of sorted filenames to create a sorted list of pathlib.Paths without the need of re-sorting (do mathematicians call this isomorphism, a property of ordered bijection? --my school days were long ago).
I think that would be a great feature since pathlib.Paths and string filenames are used in many contexts as if they were the same thing (os and os.path modules, for instance).
What do you think?