3 ms·
You can do, or you can just skip all the spaces and extra quotes and junk and just use literal /. path = f"{HOME}/cards/{card_id}/card.yaml" Easier to rea
by coldpie 3y ago
You can do, or you can just skip all the spaces and extra quotes and junk and just use literal /.
path = f"{HOME}/cards/{card_id}/card.yaml"
Easier to read & write IMO, and works fine. Even on Windows.
- skinner927 3y agoI really think they goofed Pathlib because of this. path = Path(“/foo”) / “a” / “b” / “c” The following is functionally equivalent to the above: path = Path(“/foo”) / “a/b/c” Which I really think was a mistake. The latter should resolve to “/foo/a\/b\/c” (IMO) because all other invalid characters (like space) are auto-escaped. What’s the point of the overloaded div operator otherwise?
- glandium 3y agospace is a valid character in paths. / is not. Never.
- ldjb 3y agoClassic Mac OS used colon (:) as the path separator, so slashes were perfectly acceptable in file and directory names. Even in modern versions of macOS, the GUI still allows you to create files and folders with slashes in their names; the slashes get recorded as colons in the filesystem.