[Python-ideas] Better stdlib support for Path objects

Antoine Pitrou solipsis at pitrou.net
Tue Oct 7 01:58:21 CEST 2014


Hi,

Not inheriting from built-in classes such as str, list or tuple
was one of the design points of pathlib. It will not change in the
future ;-)

PEP 428 outlines this, but you can probably find a more detailed
discussion in the python-ideas archive.

Regards

Antoine.


On Tue, 07 Oct 2014 00:52:55 +0100
MRAB <python at mrabarnett.plus.com> wrote:
> On 2014-10-07 00:40, Alexander Belopolsky wrote:
> >
> > On Mon, Oct 6, 2014 at 7:26 PM, Juancarlo Añez <apalala at gmail.com
> > <mailto:apalala at gmail.com>> wrote:
> >
> >     What do you think would be the nastier impacts of making
> >     pathlib.Path inherit from str?
> >
> >
> > Duplication of storage.  Currently, pathlib.Path objects store a list of
> > path components.  To inherit meaningfully from str, they would have to
> > store joined path string as well.
> >
> Wouldn't it also mean that it would inherit str's methods, but they
> would return instances of path, and it would need to determine the new
> path components?
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/




More information about the Python-ideas mailing list