[Python-ideas] Working with Path objects: p-strings?

Ethan Furman ethan at stoneleaf.us
Wed Mar 30 12:56:05 EDT 2016


On 03/30/2016 07:55 AM, Koos Zevenhoven wrote:
> On Wed, Mar 30, 2016 at 1:49 AM, Brett Cannon <brett at python.org> wrote:

>> Or even P.absolute and P.relative:
>>
>>    P.relative/'relative'/'path'
>>    P.absolute/'absolute'/'path'

Which involves even more typing and is less readable.


> Sometimes, in interactive sessions, I have wished for this to work:
>
>      somedir(relative_file_path).method()
>
> ...which is kind of stupid ;)

Do you mean:

   base = Path('source/antipathy')
   base('test').listdir()

I don't know about pathlib, but with antipathy's Path [1] you can do:

   base.listdir('test')

--
~Ethan~


[1] Yes, that one is mine.  The step is to make it pathlib compatible, 
which will involve, at a minimum, renaming some attributes.


More information about the Python-ideas mailing list