[Python-ideas] Better stdlib support for Path objects

Antoine Pitrou solipsis at pitrou.net
Tue Oct 7 15:44:59 CEST 2014


On Tue, 7 Oct 2014 09:37:10 -0400
Barry Warsaw <barry at python.org> wrote:
> On Oct 07, 2014, at 11:34 AM, Antoine Pitrou wrote:
> 
> >IMO it's reasonable, but assuming we devise a dedicated protocol for
> >getting a path's representation (e.g. __strpath__). Concrete type
> >checking should be avoided.
> 
> What would __strpath__ do that __str__ wouldn't do?  Or do you think it's
> better to explicitly disallow str-like objects that aren't path objects?

The latter.

> What I'm trying to understand is whether str(argument) is that "path protocol"
> or whether there's a good reason that something else that's specifically not
> str-ification is required.

Every object str-ifies successfully. IMO that's a good enough reason ;)

Regards

Antoine.




More information about the Python-ideas mailing list