pathlib PurePosixPath

BlindAnagram blindanagram at nowhere.com
Tue Oct 10 04:24:05 EDT 2017


On 10/10/2017 08:44, Sayth Renshaw wrote:
>>>> Hi
>>>>>> How do I create a valid file name and directory with pathlib?
>>>>>> When I create it using PurePosixPath I end up with an OSError due to an obvously invlaid path being created.
>>>> You're on Windows. The rules for POSIX paths don't apply to your file
>> system, and...
>>>>> OSError: [Errno 22] Invalid argument: 'C:\\Users\\Sayth\\Projects\\results/Warwick Farm2017-09-06T00:00:00.json'
>>>> ... the colon is invalid on Windows file systems. You'll have to
>> replace those with something else.
>>>> ChrisA
>> Thanks. Updated the script. But shouldn't it create the file if it doesn't exist? Which none of them will.

The documentation says "Pure path objects provide path-handling
operations which don’t actually access a filesystem".
But the "Concrete paths" subclass is described later with support for a
number of file system operations.


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /