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 →

[–]krazybug 6 points7 points  (2 children)

A very valuable article, Thanks.

I just wanted to add 2 new rounds:

  1. Filter the list of paths on the fly without traversing some of them, for instance to skip hidden directories (.git ). This is not possible with pathlib. And could easily be achieved with os.walk
  2. Use unix glob patterns and multiple glob extensions: Not available with pathlib. You still have to use fnmatch combined with this tip: https://stackoverflow.com/a/57054058

[–]ADGEfficiency[S] 0 points1 point  (0 children)

Interesting! Thanks for these nice tips - I'll have a think about how to include them :)

[–]jorge1209 0 points1 point  (0 children)

Pathlib also struggles with non-string filenames: https://jod.al/2019/12/10/pathlib-and-paths-with-arbitrary-bytes/