[Python-ideas] Better stdlib support for Path objects

Stephen J. Turnbull stephen at xemacs.org
Tue Oct 7 16:59:47 CEST 2014


Donald Stufft writes:
 > > On Oct 7, 2014, at 9:25 AM, random832 at fastmail.us wrote:

 > > It makes about as much sense for os.open to accept a path as it would
 > > for it to return a TextIOWrapper instead of an int. The same applies, in
 > > reverse, to built-in open.
 > 
 > I might agree with you if there wasn’t 20 years of code that
 > expects to be able to pass a “path” in to various places. Having to
 > keep a mental note, or worse look up in the documentation every
 > time, where I’m expected to pass a Path object and where I’m
 > expected to pass a str is just about the worst UX I can imagine.

You wouldn't need a mental memo.  Just do "import os" rather than
"from os import *" and the "os." prefix will tell you you need a str.
Otherwise use a Path.

That would be the goal, I expect.  How to get there, I'm not sure.






More information about the Python-ideas mailing list