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

Oleg Broytman phd at phdru.name
Sat Oct 6 14:26:42 CEST 2012


On Sat, Oct 06, 2012 at 02:09:24PM +0200, Antoine Pitrou <solipsis at pitrou.net> wrote:
> On Fri, 5 Oct 2012 23:16:55 -0600
> Eric Snow <ericsnowcurrently at gmail.com>
> 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:
> 
> The concrete Path objects' replace() method already maps to
> os.replace().

   Call it "with":

newpath = path.with_drive('C:')
newpath = path.with_name('newname')
newpath = path.with_ext('.zip')

Oleg.
-- 
     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