PEP on path module for standard library

John Machin sjmachin at lexicon.net
Fri Jul 22 17:22:16 EDT 2005


Michael Hoffman wrote:
> John Roth wrote:
> 
>> However, a path as a sequence of characters has even less
>> meaning - I can't think of a use, while I have an application
>> where traversing a path as a sequence of path elements makes
>> perfect sense: I need to descend the directory structure, directory
>> by directory, looking for specific files and types.
> 
> 
> I *have* used a path as a sequence of characters before. I had to deal 
> with a bunch of filenames that were formatted like "file_02832.a.txt"

Ya, ya , ya, only two days ago I had to lash up a quick script to find 
all files matching r"\d{8,8}[A-Za-z]{0,3}$" and check that the expected 
number were present in each sub-directory (don't ask!).

BUT you are NOT using "a path as a sequence of characters". Your 
filename is a path consisting of one element. The *element* is an 
instance of basestring, to which you can apply all the string methods 
and the re module.


> 
> I can see the case for a path as a sequence of elements, although in 
> practice, drive letters, extensions, and alternate streams complicate 
> things.
> 






More information about the Python-list mailing list