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

Ethan Furman ethan at stoneleaf.us
Sat Oct 6 18:20:00 CEST 2012


Stephen J. Turnbull wrote:
> Antoine Pitrou writes:
>> Richard Oudkerk wrote:
>>> Maybe p.basename could be shorthand for p.name.split('.')[0].
>> 
>> Wouldn't there be some confusion with os.path.basename:
>> 
>>--> os.path.basename('a/b/c.ext')
>> 'c.ext'

I wouldn't worry too much about this; after all, we are trying to 
replace a primitive system with a more advanced, user-friendly one.


> Also there are applications where "basenames" contain periods (eg,
> wget often creates directories with names like "www.python.org"), and
> filenames may have multiple extensions, eg, "index.ja.html".
> 
> I think it's reasonable to define "extension" to mean "the portion
> after the last period (if any, maybe including the period), but I
> think usage of the complementary concept is pretty application-
> specific.

FWIW, my own implementation uses the names

.path  -> c:\foo\bar  or  \\computer_name\share\dir1\dir2
.vol   -> c:              \\computer_name\share
.dirs  ->   \foo\bar                           \dir1\dir2

.filename ->  some_file.txt  or  archive.tar.gz
.basename ->  some_file          archive
.ext      ->           .txt             .tar.gz

~Ethan~



More information about the Python-ideas mailing list