[Python-ideas] PEP 428 - object-oriented filesystem paths

Oleg Broytman phd at phdru.name
Sat Oct 6 11:55:53 CEST 2012

On Sat, Oct 06, 2012 at 05:04:44PM +0900, "Stephen J. Turnbull" <stephen at xemacs.org> wrote:
>  > Eric Snow wrote:
>  > > Each namedtuple has a _replace() method that's is used to generate a
>  > > new instance with one or more attributes changed.  We could do
>  > > something similar here:
>  > > 
>  > >>>> p = PureNTPath('c:/orders/12345/abc67890.dbf')
>  > >>>> p.replace(ext='.csv')
>  > > PureNTPath('c:\\orders\\12345\\abc67890.csv')
> 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.

   I think this would be overgeneralization. IMO there is no need to
replace parts beyond drive/name/extension. To "replace" root or path
components just construct a new Path.

     Oleg Broytman            http://phdru.name/            phd at phdru.name
           Programmers don't die, they just GOSUB without RETURN.

More information about the Python-ideas mailing list