Tim Peters wrote:
[Frans Englich]
...
[snip]
class HasPath:
def __init__(self, path):
self.path = path
def __lt__(self, other):
return self.path < other.path
class Directory(HasPath):
def __init__(self, path):
HasPath.__init__(self, path)
self.files = []
[Frans Englich]
...
> My problem, AFAICT, with using os.walk() the usual way, is that in order to
> construct the /hierarchial/ XML document, I need to be aware of the directory
> depth, and a recursive function handles that nicely; os.walk() simply
> concentrates on figuring out paths to all files
Robert Kern wrote:
> Fernando Perez wrote:
>
>> Perhaps this path.py could be considered for inclusion in the stdlib? I've
>> only
>> read the page linked above, so perhaps it can use some polishing. But it
>> certainly looks like a big improvement over the scatterblast which the stdlib
>> is o
Fernando Perez wrote:
Perhaps this path.py could be considered for inclusion in the stdlib? I've only
read the page linked above, so perhaps it can use some polishing. But it
certainly looks like a big improvement over the scatterblast which the stdlib
is on this particular topic.
I'm pretty sure
Michael Spencer wrote:
> The path module by Jorendorff: http://www.jorendorff.com/articles/python/path/
>
> wraps various os functions into an interface that can make this sort of thing
> cleaner
Wow, many thanks for the pointer. This has to be one of the single most useful
small python modules
Frans Englich wrote:
Hello,
Have a look at this recursive function:
def walkDirectory( directory, element ):
element = element.newChild( None, "directory", None ) # automatically
appends to parent
element.setProp( "name", os.path.basename(directory))
for root, dirs, files in os.walk(
Hello,
Have a look at this recursive function:
def walkDirectory( directory, element ):
element = element.newChild( None, "directory", None ) # automatically
appends to parent
element.setProp( "name", os.path.basename(directory))
for root, dirs, files in os.walk( directory ):