[issue38222] pathlib Path objects should support __format__

Serhiy Storchaka report at bugs.python.org
Thu Sep 19 10:31:08 EDT 2019


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

I am -0 on this. It is a can of worms. Once we add a trivial __format__ in Path, we will need to handle numerous requests for adding a trivial __format__ in many other classes. It is better to teach users to use !s (and this works also on older Python versions!).

As for Path, there many ways to convert it to string: str(), repr(), os.fspath(), os.fsdecode(), Path.as_posix(), Path.as_uri(), with possible normalization, converting to absolute or relative path. I would not bet that we will never have reasons to have a different format specifier language for Path.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38222>
_______________________________________


More information about the Python-bugs-list mailing list