Use of cmp() (was Re: Limitation of os.walk)

2010-05-12 Thread Aahz
[nitpicking one specific point] In article , Steven D'Aprano wrote: > >On the other hand a cmp function is specific to sorting, and nothing >but sorting. Not quite. cmp() is useful any time you have an expensive comparison operation and you need to take three different codepaths depending on t

Re: Limitation of os.walk

2010-05-12 Thread Steven D'Aprano
On Wed, 12 May 2010 19:04:47 +, kj wrote: > In Terry Reedy > writes: > >>On 5/11/2010 3:49 PM, kj wrote: >>> PS: I never understood why os.walk does not support hooks for key >>> events during such a tree traversal. > >>Either 1) it is intentionally simple, with the expectation that people

Re: Limitation of os.walk

2010-05-12 Thread Terry Reedy
On 5/12/2010 2:52 PM, kj wrote: In Tim Chase writes: 05/11/2010 09:07 PM, Terry Reedy wrote: If os.walk were rewritten, it should be as an iterator (generator). Directory entry and exit functions could still be added as params. It *is* an iterator/generator. However, I suspect you mean t

Re: Limitation of os.walk

2010-05-12 Thread Patrick Maupin
On May 12, 2:04 pm, kj wrote: > It seems that a similar "simplicity argument" was invoked > to strip the cmp option from sort in Python 3.  G.  Simplicity > is great, but when the drive for it starts causing useful functionality > to be thrown out, then it is going too far.  Yes, I know that i

Re: Limitation of os.walk

2010-05-12 Thread kj
In Terry Reedy writes: >On 5/11/2010 3:49 PM, kj wrote: >> PS: I never understood why os.walk does not support hooks for key >> events during such a tree traversal. >Either 1) it is intentionally simple, with the expectation that people >would write there own code for more complicated uses or

Re: Limitation of os.walk

2010-05-12 Thread kj
In Tim Chase writes: > 05/11/2010 09:07 PM, Terry Reedy wrote: >> If os.walk were rewritten, it should be as an iterator (generator). >> Directory entry and exit functions could still be added as params. >It *is* an iterator/generator. However, I suspect you mean that >it should slurp the dirs

Re: Limitation of os.walk

2010-05-11 Thread Tim Chase
05/11/2010 09:07 PM, Terry Reedy wrote: PS: I never understood why os.walk does not support hooks for key events during such a tree traversal. Either 1) it is intentionally simple, with the expectation that people would write there own code for more complicated uses or 2) no one has submitted

Re: Limitation of os.walk

2010-05-11 Thread Terry Reedy
On 5/11/2010 3:49 PM, kj wrote: I want implement a function that walks through a directory tree and performs an analsysis of all the subdirectories found. The task has two essential requirements that, AFAICT, make it impossible to use os.walk for this: 1. I need to be able to prune certain d

Re: Limitation of os.walk

2010-05-11 Thread kj
In Tim Chase writes: >That said, the core source for os.walk() is a whole 23 >lines of code, it's easy enough to just clone it and add what you >need... Thanks, that was a good idea. ~K -- http://mail.python.org/mailman/listinfo/python-list

Re: Limitation of os.walk

2010-05-11 Thread Tim Chase
On 05/11/2010 02:49 PM, kj wrote: I want implement a function that walks through a directory tree and performs an analsysis of all the subdirectories found. The task has two essential requirements that, AFAICT, make it impossible to use os.walk for this: 1. I need to be able to prune certain di

Limitation of os.walk

2010-05-11 Thread kj
I want implement a function that walks through a directory tree and performs an analsysis of all the subdirectories found. The task has two essential requirements that, AFAICT, make it impossible to use os.walk for this: 1. I need to be able to prune certain directories from being visited. 2.