Re: [Python-ideas] Path conversion for f-strings

2019-05-13 Thread Serge Matveenko
On Mon, May 13, 2019 at 4:44 AM Batuhan Taskaya  wrote:
>
> 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().

Hi! Honestly, I feel a lack of use case context here.

Just to mention, `pathlib.Path` like objects have there `__str__`
implement to return a string representation of the path, i.e.
`str(pathlib.Path("/home/batuhan"))` returns `"/home/batuhan"`
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Path conversion for f-strings

2019-05-12 Thread Batuhan Taskaya
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().
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/