[Python-checkins] peps: Clarify why pathlib doesn't inherit from str

Ethan Furman ethan at stoneleaf.us
Fri Apr 22 14:54:32 EDT 2016


On 04/22/2016 11:45 AM, brett.cannon wrote:

> +The key reasoning behind not inheriting from ``str`` is to prevent confusing
> +any object that has a string representation -- which is all Python objects --
> +with a path object.

That doesn't make sense.

   isinstance(Path('/home/ethan/.profile'), str)

is orthogonal to

   str({a:1, b:2}).

Preventing confusion with any object is why were discussing a new protocol.

--
~Ethan~


More information about the Python-checkins mailing list