[Python-ideas] pathlib suggestion

Thomas Heller theller at ctypes.org
Wed May 21 08:58:48 CEST 2014


Am 20.05.2014 17:25, schrieb Antoine Pitrou:
> On Tue, 20 May 2014 10:51:22 +0200
> Thomas Heller <theller at ctypes.org> wrote:
>> Python 3.4's pathlib uses str(path) to get the full pathname
>> as string.
>>
>> I'd like to suggest adding a property which allows to access
>> the full pathname.  IMO this should make it easier to understand
>> the code or make if possible to search for it in sources.
>>
>> I'm unsure about the name this property should get; maybe .fullpath
>> or something like that.  I'm also unsure whether there should be
>> separate properties to get the full pathname as string or bytes object.
>
> .strpath perhaps?
> (also .bytespath if desired)

The names .strpath and .bytespath look good to me.

>
> It was once proposed as "filesystem path" protocol where classes
> purporting to represent filesystem paths could define a e.g.
> __strpath__ method returning the string representation of the path.  I
> can only find the following allusions on python-ideas:
> https://mail.python.org/pipermail/python-ideas/2012-October/016912.html
> https://mail.python.org/pipermail/python-ideas/2012-October/016974.html

This is not directly related of my proposal, but it may be a good
idea.  So __strpath__() would return the .strpath property?

Thomas




More information about the Python-ideas mailing list