[Python-ideas] Promoting the adoption of pathlib [Was: Working with Path objects: p-strings?]

Random832 random832 at fastmail.com
Thu Mar 31 16:56:59 EDT 2016


On Thu, Mar 31, 2016, at 16:44, Greg Ewing wrote:
> Paul Moore wrote:
> >     In function xxx, please support passing a pathlib.Path for
> > argument bar. This can be done
> >     simply by adding a line
> >         bar = getattr(bar, 'path', bar)
> 
> This is a rather ugly piece of code to have to sprinkle
> all over any library that deals with pathnames.
> 
> I don't get a good feeling about this approach. It seems
> like it will be a spreading infection that only gets
> worse over time.

If os and io (and open builtin) supported it, I bet that 90% of other
modules wouldn't need to do anything to support it. io/open might not
even need to explicitly support it. Duck typing = a filename is anything
that can be passed to open / some os functions.


More information about the Python-ideas mailing list