[Python-ideas] Path conversion for f-strings

Batuhan Taskaya isidentical at gmail.com
Sun May 12 21:43:35 EDT 2019


Like repr and string the file system path is used alot and something like
path!p might be handy.

>>> class MyClass:
...     def __fspath__(self):
...         return "/home/batuhan"
...
>>> assert f"{mc!p}" == f"{os.fspath(mc)}"

Also it saves us to unnecessarily import os for only fspath().
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190513/8a9b8a87/attachment.html>


More information about the Python-ideas mailing list