PEP on path module for standard library

Michael Hoffman cam.ac.uk at mh391.invalid
Thu Jul 21 23:36:51 CEST 2005


Reinhold Birkenfeld wrote:
> FYI: I modified the path module a bit so that it fits many of the suggestions
> from python-dev, and put the result in the Python CVS tree under
> nondist/sandbox/path.
> 
> Most prominent change is that it doesn't inherit from str/unicode anymore.
> I found this distinction important, because as a str subclass the Path object
> has many methods that don't make sense for it.

Having path descend from str/unicode is extremely useful since I can 
then pass a path object to any function someone else wrote without 
having to worry about whether they were checking for basestring. I think 
there is a widely used pattern of accepting either a basestring[1] or a 
file-like object as a function argument, and using isinstance() to 
figure out which it is.

What do you gain from removing these methods? A smaller dir()?

[1] Probably str in actuality.
-- 
Michael Hoffman



More information about the Python-list mailing list