newbie class troubles

Tim Peters tim_one at email.msn.com
Sun Sep 17 14:26:01 EDT 2000


[Brett Lempereur]
> I'm trying to write a recursive file search function based on the
> os.path.walk() function, however when i come to run the search funtion
> (which is contained within a class) i get this error: "TypeError: unbound
> method must be called with class instance 1st argument".  Can 
> anybody help?

Hmm.  As later replies confirmed, you're a man of few words <wink>.

In this case, my guess is that you have something that looks like:

class C:
    ...
    def search(self, top):
        ...

import os
os.path.walk(path, C.f, ())

but that you really want something more like:

class C:
    ...
    def search(self, dontcare, top, names):
        ...

c = C()
os.path.walk(path, c.f, ())

If you answer just "no", we'll kill you <wink>.





More information about the Python-list mailing list