newbie class troubles

Alex cut_me_out at
Sun Sep 17 20:15:01 CEST 2000

> class filesearch:
>     # Any public variables i need
>     exceptions = []
>     filelist = []
>     dirlist = []
>     def search(self, top):
> 	  try:
> 	      tmpList = os.listdir(top)
> 	  except os.error:
> 	      return
> 	  for item in tmpList:
> 	      if item not in exceptions:
> 		  name = os.path.join(top, name)
> 		  if os.path.isdir(name):
> 		      self.dirlist.append(name)
> 		      search(self, name)
> 		  else:
> 		      self.filelist.append(name)

You're being pretty unclear, but I would guess that you were trying to
use this class in some fashion as

os.path.walk(dir,, 'dummy_arg')

If that's the case, the error is coming from the fact that is an unbound method.   To correct it, you need to do
something like this, instead:

filesearch_instance = filesearch()
os.path.walk(dir,, 'dummy_arg')

You will probably also need to amend the argument signature of the
search method.  It will probably need to take three arguments, not one.


Speak softly but carry a big carrot.

More information about the Python-list mailing list