[Python-ideas] Working with Path objects: p-strings?
Koos Zevenhoven
k7hoven at gmail.com
Wed Mar 30 13:51:53 EDT 2016
On Wed, Mar 30, 2016 at 7:56 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> On 03/30/2016 07:55 AM, Koos Zevenhoven wrote:
>>
>> 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()
Yes, I think. That is, equivalent to (base / 'test').listdir()
>
> I don't know about pathlib, but with antipathy's Path [1] you can do:
>
> base.listdir('test')
>
I have wished for base.mkdir("subdir") too, but the addition to
pathlib would be backwards incompatible for people that give the mode
argument as a positional argument.
> [1] Yes, that one is mine. The step is to make it pathlib compatible, which
> will involve, at a minimum, renaming some attributes.
I wonder if it is still possible to rename pathlib attributes (and
keep the old ones as deprecated aliases for a while), now that the
adoption of pathlib is still limited.
-Koos
More information about the Python-ideas
mailing list