this actually came up fairly recently on this very list -- go poke around in the archives to find it.

But the short version is that there is no clear definition of a "sanitized" filename -- see that SO thread to get the idea. So you really want a solution that works for your use case, so not really a candidate for the standard library.

There are a number of packages on PyPi that might help:

https://pypi.org/project/pathvalidate/

https://pypi.org/project/awesome-slugify/

just to name two.

-CHB


On Tue, Aug 11, 2020 at 10:51 PM Charles Machalow <csm10495@gmail.com> wrote:
I was reading https://stackoverflow.com/questions/7406102/create-sane-safe-filename-from-any-unsafe-string and was thinking that functionality to create safe paths from unsafe paths and check if a Path would work on a given filesystem would well in Pathlib.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/5BVZGNLG6EHVC4APG7Z2L56VLSUJRXJX/
Code of Conduct: http://python.org/psf/codeofconduct/


--
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython