pathlib PurePosixPath

Tim Golden mail at timgolden.me.uk
Tue Oct 10 06:18:26 EDT 2017


On 2017-10-10 10:58, Chris Angelico wrote:
> On Tue, Oct 10, 2017 at 8:56 PM, Tim Golden <mail at timgolden.me.uk> 
> wrote:
>>> My understanding of the document you linked to
>>> is that the colon still has special meaning, and thus you can't use 
>>> it
>>> in arbitrary file names.
>> 
>> 
>> In fact its presence in that filename creates a (usually hidden) data 
>> stream
>> piggybacked onto that file which has the name "abc" into which the 
>> data is
>> written.
>> 
>> So, following on, the follow works:
>> 
>> assert open("temp.txt:abc").read() == "abc"
> 
> Cool. Does it require that temp.txt exist first? And if you have
> multiple colons (as in the OP's), does the part after the second colon
> have to be a type indicator?
> 
> ChrisA

No. temp.txt is created empty.

Multiple colons *does* appear to be a syntax error in the filename.

TJG



More information about the Python-list mailing list