[Python-ideas] URLs/URIs + pathlib.Path + literal syntax = ?

Paul Moore p.f.moore at gmail.com
Wed Mar 30 03:55:33 EDT 2016


On 30 March 2016 at 05:23, Chris Angelico <rosuav at gmail.com> wrote:
>> 4)  Path("file:///http://www.example.com")
>
> Oops, my bad - I forgot about the third slash. It comes to the same
> thing, though; for most paths, you can deduce that a prefix "http://"
> implies that it's not a file path, and for the rare case when you do
> mean that, you can explicitly adorn it.

I presume you're deliberately ignoring the fact that most paths come
from variables, not from literals, and many come from user input
(sometimes even unintended user input such as a "*" expanded by the
shell)? It's easy enough to rewrite literals to be unambiguous, but in
order to do so for arbitrary input you need to basically implement
(part of) a URI parser...

Paul


More information about the Python-ideas mailing list