[Python-Dev] pathlib - current status of discussions (original) (raw)
Random832 random832 at fastmail.com
Thu Apr 14 12🔞18 EDT 2016
- Previous message (by thread): [Python-Dev] pathlib - current status of discussions
- Next message (by thread): [Python-Dev] pathlib - current status of discussions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Apr 14, 2016, at 12:05, Stephen J. Turnbull wrote:
Random832 writes:
> And what such incompatibilities exist between bytes and str for the > purpose of representing file paths? A plethora of encodings.
Only one encoding, fsencode/fsdecode. All other encodings are not for filenames.
> At the end of the day, there's exactly one answer to "what file on > disk this represents (or would represent if it existed)".
Nope. Suppose those bytes were read from a file or a socket? It's dangerous to assume that encoding matches the file system's.
Why can I pass them to os.open, then, or to os.path.join so long as everything else is also bytes?
On UNIX, the filesystem is in bytes, so saying that bytes can't match the filesystem is absurd. Converting it to str with fsdecode will always, absolutely, 100% of the time give a str that will address the same file that the bytes does (even if it's "dangerous" to assume that was the name the user wanted, that's beyond the scope of what the module is capable of dealing with).
- Previous message (by thread): [Python-Dev] pathlib - current status of discussions
- Next message (by thread): [Python-Dev] pathlib - current status of discussions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]