[Python-ideas] Better stdlib support for Path objects

random832 at fastmail.us random832 at fastmail.us
Mon Oct 6 23:55:47 CEST 2014


On Mon, Oct 6, 2014, at 14:04, Guido van Rossum wrote:
> I'd turn it around.
> 
> You can construct a Path from an argument that can be either a string or
> another Path. Example:
> 
> >>> from pathlib import Path
> >>> p = Path('/etc/passwd')
> >>> q = Path(p)
> >>> p == q
> True
> >>>
> 
> So you could start refactoring stdlib code to use Path internally without
> forcing the callers to use Path, but still *allow* the callers to pass a
> Path. Though I'm not sure how this would work for return values without
> breaking backwards compatibility -- you'd have to keep returning strings
> and the callers would have to use the same mechanism to go back to using
> Paths.

Should Path accept a bytes? It doesn't appear to now.


More information about the Python-ideas mailing list