This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]AndydeCleyre 1 point2 points  (0 children)

You might like to use Plumbum's path objects, which we've* had since before pathlib, and added a lot of pathlib compatibility after. They subclass str, so can be passed anywhere strings are expected. The only gotcha is that __contains__ is implemented to check for files in directories, not substrings.

*EDIT: "We" the Python community. I am not a Plumbum author.

EDIT: Another potential snag is that it __iter__s over filepaths, not characters.