[Python-ideas] PEP 428 - object-oriented filesystem paths
Eric Snow
ericsnowcurrently at gmail.com
Sat Oct 6 19:41:00 CEST 2012
On Sat, Oct 6, 2012 at 6:26 AM, Oleg Broytman <phd at phdru.name> wrote:
> 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')
Yeah, having dedicated methods makes more sense here, given the small
number of candidates for replacement.
-eric
More information about the Python-ideas
mailing list