[issue22570] Better stdlib support for Path objects

Ram Rachum report at bugs.python.org
Wed Jan 6 04:38:47 EST 2016


Ram Rachum added the comment:

I thought about it some more, and personally I'd prefer each function to do `str(path)` internally rather than `if hasattr(p, 'path'): p = p.path`. Even if it means we'll have to deal with "where did that file named '<type object at ...>' come from?!" errors. I think it's clumsy that the path protocol is to access `path.path`. We already have a protocol for getting a string out of an object and it's `str(object)`. I think we should use it even if it makes debugging harder in the case where someone mistakenly passes a non-path object to a function that wants a path. (And without using `isinstance` either.)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22570>
_______________________________________


More information about the Python-bugs-list mailing list