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

Ethan Furman ethan at stoneleaf.us
Sun Oct 7 03:13:17 CEST 2012


Ben Finney wrote:
> Antoine Pitrou <solipsis at pitrou.net>
> writes:
> 
>>     >>> p = Path('/home/antoine/pathlib/setup.py')
>>     >>> p.name
>>     'setup.py'
>>     >>> p.ext
>>     '.py'
> 
> The term “extension” is a barnacle from mainframe filesystems where a
> filename is necessarily divided into exactly two parts, the name and the
> extension. It doesn't really apply to POSIX filesystems.
> 
> On filesystems where the user has always been free to have any number of
> parts in a filename, the closest concept is better referred to by the
> term “suffix”::
> 
>     >>> p.suffix
>     '.py'
> 
> It may be useful to add an API method to query the *sequence* of
> suffixes of a filename::
> 
>     >>> p = Path('/home/antoine/pathlib.tar.gz')
>     >>> p.name
>     'pathlib.tar.gz'
>     >>> p.suffix
>     '.gz'
>     >>> p.suffixes
>     ['.tar', '.gz']

+1




More information about the Python-ideas mailing list