On 30Jan2013 13:26, Guido van Rossum email@example.com wrote: | Thoughts on os.path? What happened to the idea of a new path object? [...] | From: Talin firstname.lastname@example.org [...] | On Wed, Jan 30, 2013 at 11:33 AM, Guido van Rossum email@example.com wrote: | > Hmm... Mind if I just forward to python-dev? IIRC there's been some | > discussion about a newfangled path object, but I lost track of where | > the discussion went. (Or you can post there yourself. :-) | | Sure - forward away. Is this the same as the path object idea that was | floated 5 years ago? I've yet to see any set of convenience methods | for paths that are so compelling as to be worth all of the time and | energy needed to update all of the various APIs which now expect paths | to be passed in as strings.
Speaking for myself, I've been having some usefulness with making "URL" objects that are subclasses of str. That lets me pass them to all the things that already expect strs, while still having convenience methods.
Combined with a little factory function to make a "URL" from a bare str should it be needed, it has worked fairly well. It is certainly not seamless all the time...
Eg: U = URL(s) # returns s if already an instance of _URL len(U) # I'm still a string U.startswith("http:") U.scheme # eg "http" U.hrefs # fetch content, parse as HTML, return links
Just a thought on supporting code expecting strings.