[Python-ideas] PEP 428 - object-oriented filesystem paths
Georg Brandl
g.brandl at gmx.net
Sat Oct 6 15:08:27 CEST 2012
Am 06.10.2012 14:57, schrieb Antoine Pitrou:
> On Sat, 06 Oct 2012 14:55:16 +0200
> Georg Brandl <g.brandl at gmx.net> wrote:
>> Am 06.10.2012 14:46, schrieb Antoine Pitrou:
>> > On Sat, 6 Oct 2012 16:40:49 +0400
>> > Oleg Broytman <phd at phdru.name> wrote:
>> >> On Sat, Oct 06, 2012 at 04:26:42PM +0400, Oleg Broytman <phd at phdru.name> wrote:
>> >> > newpath = path.with_drive('C:')
>> >> > newpath = path.with_name('newname')
>> >> > newpath = path.with_ext('.zip')
>> >>
>> >> BTW, I think having these three -- replacing drive, name and extension --
>> >> is enough.
>> >
>> > What is the point of replacing the drive?
>> >
>> > Replacing the name is already trivial: path.parent()[newname]
>> >
>> > So we only need to replace the "basename" and the extension (I think
>> > I'm ok with the "basename" terminology now :-)).
>>
>> If my crystal ball is correct, the middle example above replaces not the
>> basename but the "part before the extension". So we have to find another
>> name for it ...
>
> Well, "basename" is the name proposed for the "part before the
> extension". "name" is the full filename.
>
> (so path.name == path.basename + path.ext)
Is it? You said yourself it was easily confused with os.path.basename()'s result.
Georg
More information about the Python-ideas
mailing list