[Python-ideas] Working with Path objects: p-strings?
Brett Cannon
brett at python.org
Tue Mar 29 17:37:23 EDT 2016
On Tue, 29 Mar 2016 at 11:59 Random832 <random832 at fastmail.com> wrote:
> On Tue, Mar 29, 2016, at 14:51, Brett Cannon wrote:
> > OK, so if all paths can be represented as strings, why don't we just make
> > `pathlib.Path` subclass `str`? Well, as I said earlier, not all strings
> > are
> > paths. You can't concatenate a string representing a path with some other
> > random string and expect to get back a string that still represents a
> > valid
> > string
>
> I assume you mean a valid path.
>
Yep, it's a typo.
>
> You can't add an int to a float and expect to get an integer back,
> either.
Sure, but that's because int and float are both part of the same type
hierarchy (https://www.python.org/dev/peps/pep-3141/).
> If you're adding it to a random string you're clearly not using
> it in a path context, and the type of the result won't be Path anyway.
>
You're assuming it's always clear. If that was always true then no one
would ever find a bug in their code when porting to Python 3. We can all
assume we won't screw up, but the fact bugs exist shows that's not true.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160329/63197597/attachment.html>
More information about the Python-ideas
mailing list