Newbie Question
Emile van Sebille
emile at fenx.com
Fri Dec 22 11:13:58 EST 2000
I see what you mean. I've built a test that appears to
work, but I don't immediately see the material difference
between this and what your code does.
import os
class Class:
def func(self, root, files):
print self
print root
print files
arg = Class()
root = r'C:\etvwin'
os.path.walk(root, Class.func, arg)
HTH,
--
Emile van Sebille
emile at fenx.com
-------------------
"Bob W." <removethis_kranki2 at earthlink.net> wrote in message
news:hqs64tc5jjndav3p6nvmu67t7hqaf5go00 at 4ax.com...
> I tried using "self" in the os.path.walk and I get an
error saying
> that there 3 expected arguments, but got 4 in ntpath.py,
line 264.
> That was my preferred way of simulating a C++ private
method.
> Thanks for any help provided!
>
> On Fri, 22 Dec 2000 13:44:23 GMT, Bob W.
> <removethis_kranki2 at earthlink.net> wrote:
>
> >I am trying to write the following class, but it fails in
the Run()
> >method reference to __CheckFile and I am not sure how to
get it to
> >work. Thanks in advance for your help!
> >
> >class RmwExpireCheck:
> > def __init__( self, szFileName, szDir ):
> > self.szFileName = szFileName
> > FileStatList = os.stat( szFileName )
> > if FileStatList:
> > self.iCheckDate = FileStatList[8]
> > self.szDir = szDir
> > self.szFileList = []
> >
> > def __getitem__(self, i):
> > line = self.szFileList[i]
> > if line:
> > return line
> > else:
> > raise IndexError
> >
> > def __CheckFile( self, szDirName, szFileNames ):
> > for szFileName in szFileNames:
> > szPathName = os.path.join( szDirName,
szFileName )
> > if os.path.isfile( szPathName ):
> > iFileTime = os.stat( szPathName )[8]
> > if iFileTime > self.iCheckDate:
> > self.szFileList.append( szPathName )
> >
> > def Run( self ):
> > os.path.walk( self.szDir,
RmwExpireCheck.__CheckFile, self )
> >
> >
>
More information about the Python-list
mailing list