Python 2.8?
Python 2.8?
Posted Jan 14, 2017 0:15 UTC (Sat) by vstinner (subscriber, #42675)In reply to: Python 2.8? by Cyberax
Parent article: Python 2.8?
Python 3 supports Unicode and bytes, both work perfectly fine. Using Unicode on Linux, you *can* handle any filename, including filenames not decodable from the locale encoding. Just try (ex: non-ASCII filename but POSIX locale, LC_ALL=C), you will see (os.listdir() doesn't fail, but print(filename) can fail). On Windows, using bytes is more weird, but it should "just work" since Python 3.6.
But you missed the point. The "fspath" protocol is unrelated to "bytes vs Unicode", it's only an enhancement to support custom objects like pathlib.Path, accept them in functions expecting a filename like open(). See the What's New in Python 3.6 for an example:
https://docs.python.org/dev/whatsnew/3.6.html#pep-519-add...
You are free to not use pathlib. It seems like some users prefer pathlib over handling "manually" paths using os.path.join() for example.