[SciPy-User] Curse of recursive directory walking
Wed Jul 29 22:19:10 CDT 2009
On Wed, Jul 29, 2009 at 6:25 PM, <email@example.com> wrote:
> On Wed, Jul 29, 2009 at 5:14 PM, Gökhan SEVER<firstname.lastname@example.org>
> > On Wed, Jul 29, 2009 at 9:48 AM, <email@example.com> wrote:
> >> To me it looks more like it is a problem with relative file paths and
> >> changing directories and not with recursion.
> >> I never had problems with os.walk or any home made recursive directory
> >> walker, but I always used absolute paths.
> >> from the python 2.5 docs
> >> Note: If you pass a relative pathname, don't change the current
> >> working directory between resumptions of walk(). walk() never changes
> >> the current directory, and assumes that its caller doesn't either.
> >> Josef
> > I have one more question on os.walk()
> > For some reason while this function working on my local folders I walks
> > through them in a randomly manner. However when I run the same script on
> > network mounted drive (using the same directory structure) it walks
> > them in an alphabetically sorted order.
> > Have you encountered a similar behaviour before?
> I only use windows, and it looks like I get windows fileordering,
> alphabetically, independent of capitalization, and not capitalized
> names sorted first. So I assume that the ordering depends on the
> operating system.
> to get deterministic ordering, inplace sorting should be possible, but
> I never tried
> python help: When topdown is true, the caller can modify the dirnames
> list in-place
> help for os.listdir says about the list of directory entries: "The
> list is in arbitrary order"
This is Fedora 11.
I still couldn't figure out why os.walk() preserves the fileordering
properly on samba mounted folders but not on my same local copies. The weird
thing is it always walks the given directory tree in the same arbitrary
order whenever I called the script.
Inplace listing may not be a good option, 1st I don't know how to do that,
and second when a directory under a given path is reached and if the desired
file exists under that directory it will execute my plotting script. It
works but a bizarre way :)
Maybe I should ask on a python mailing list.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User