PEP on path module for standard library
Reinhold Birkenfeld
reinhold-birkenfeld-nospam at wolke7.net
Thu Jul 21 17:53:42 EDT 2005
Michael Hoffman wrote:
> 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.
Where do you see that pattern? IIRC it's not in the stdlib.
> What do you gain from removing these methods? A smaller dir()?
It made sense to me at the time I changed this, although at the moment
I can't exactly recall the reasons.
Probably as Terry said: a path is both a list and a string.
Reinhold
More information about the Python-list
mailing list