[Python-ideas] PEP 428 - object-oriented filesystem paths
Ethan Furman
ethan at stoneleaf.us
Sat Oct 6 18:27:26 CEST 2012
Stephen J. Turnbull wrote:
> Ethan Furman writes:
>> Eric Snow wrote:
>>>--> p = PureNTPath('c:/orders/12345/abc67890.dbf')
>>>--> p.replace(ext='.csv')
>>> PureNTPath('c:\\orders\\12345\\abc67890.csv')
>>
>> +1
>
> How about a more general subst() method? Indeed, it would need
> keyword arguments for named components like ext, but I often do things
> like "mv ~/Maildir/{tmp,new}/42" in the shell. I think it would be
> useful to be able to replace any component of a path.
How would 'subst' differ from 'replace'? As you can see from the
example, the keyword 'ext' is being used to specify with component gets
replaced.
~Ethan~
More information about the Python-ideas
mailing list