Eryk Sun <eryk...@gmail.com> added the comment:
> I thought pathlib would solve this problem completely now, > without having to replace the slashes. pathlib has nothing to do with how the Python language compiles string literals. A string *literal* is Python source code that gets compiled and instantiated as a string object. There is no technical problem with using r'F:\ceven\test2'. Using a raw string literal disables backslash escapes. But many developers find it inconvenient to have to use raw strings or to have to escape backslashes by doubling them. Plus raw string literals can't represent a path that ends with a backslash, such as C:\. The Windows API supports forward slash as a path separator in many cases, but not always, and also not always for paths passed on the command line. So it's preferable to always normalize paths. pathlib takes care of this for you. You can initialize conveniently with forward slashes, but get a Windows path string that uses backslashes. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46916> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com