Re: [Tutor] os.path.walk vs unix find command

2008-08-15 Thread Steve Willoughby
Kent Johnson wrote: Is os.popen("find") faster or slower than os.path.walk to find file pattern in the The general answer to "is find faster than os.[path.]walk faster" is "it depends." Find is optimized, compiled, and fast at what it does. However, what it does is somewhat limited. If you

Re: [Tutor] os.path.walk vs unix find command

2008-08-15 Thread Kent Johnson
On Fri, Aug 15, 2008 at 6:17 PM, Angela Yang <[EMAIL PROTECTED]> wrote: > Hi Python gurus: > > Is os.popen("find") faster or slower than os.path.walk to find file pattern > in the > directory tree? I thought os.path.walk would be faster than unix find, but > that doesn't > seem to be the case? In

Re: [Tutor] os.path.walk vs unix find command

2008-08-15 Thread Chris Fuller
On Friday 15 August 2008 17:17, Angela Yang wrote: > Hi Python gurus: > > > > Is os.popen("find") faster or slower than os.path.walk to find file pattern > in the > > directory tree?  I thought os.path.walk would be faster than unix find, but > that doesn't > > seem to be the case? > > > I'd expec

[Tutor] os.path.walk vs unix find command

2008-08-15 Thread Angela Yang
Hi Python gurus: Is os.popen("find") faster or slower than os.path.walk to find file pattern in the directory tree?  I thought os.path.walk would be faster than unix find, but that doesn't seem to be the case? What is the fastest way in python to search for a file with a given pattern in

Re: [Tutor] os.path.walk

2006-08-22 Thread Alan Gauld
> Yes, that is the right way to do it and it will work fine. Something > like > > class Walker(object): > def walk(self, base): >os.path.walk(base, self.callback, None) > > What happens is, when Python looks up self.callback it converts the > method to a "bound method". Aargh! I should hav

Re: [Tutor] os.path.walk

2006-08-22 Thread Alan Gauld
> What has got me worried is that the function called by os.path.walk > must be a method of the class. > Now this means it will have something like this as a def: > > def func_called_by_walk(self, arg, directory, names): > > Will this work with os.path.walk with that definition? No, but you can w

Re: [Tutor] os.path.walk

2006-08-22 Thread Kent Johnson
nimrodx wrote: > Hi All, > > I was wondering if anyone had used os.path.walk within a class or not, > and what are the pitfalls... > > What has got me worried is that the function called by os.path.walk > must be a method of the class. > Now this means it will have something like this as a def:

[Tutor] os.path.walk

2006-08-22 Thread nimrodx
Hi All, I was wondering if anyone had used os.path.walk within a class or not, and what are the pitfalls... What has got me worried is that the function called by os.path.walk must be a method of the class. Now this means it will have something like this as a def: def func_called_by_walk(self