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

Eric Snow ericsnowcurrently at gmail.com
Sun Oct 7 02:47:56 CEST 2012


On Oct 6, 2012 6:41 PM, "Ben Finney" <ben+python at benfinney.id.au> 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

-eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20121006/7d863935/attachment.html>


More information about the Python-ideas mailing list