The "p" in p-string stands for path and one of the alternative proposals is to add the following syntactic sugar to Python like this:
p'/someroot/{myvariable}/file.ext'
This basically is supposed to create a pathlib.Path object which allows all sort of convenience methods like extracting the extension or iterating over the parts of the path and more.
Despite the usability improvement, there are of course reservations about the idea. Mainly these are:
- path vs. str (I will cover this in another post)
- tying a syntax to a stdlib module (in this case pathlib)
- security concerns about including user input (same discussion arose with f-strings back then)
If you find the proposal useful or have something else to contribute to the discussion, we look forward to seeing you on the mailing list. :)
Best,
Sven
No comments:
Post a Comment