"Maximum recursion depth exceeded"...why?

Christian Heimes lists at cheimes.de
Tue Feb 17 21:08:58 EST 2009

Thomas Allen wrote:
> If you'd read the messages in this thread you'd understand why I'm not
> using os.walk(): I'm not using it because I need my code to be aware
> of the current recursion depth so that the correct number of "../" are
> substituted in.

I'm well aware of your messages and your requirements. However you
didn't either read or understand what I was trying to tell you. You
don't need to know the recursion depths in order to find the correct
number of "../".

base = os.path.normpath(base)
baselevel = root.count(os.sep)

for root, dirs, files in os.walk(base):
    level = root.count(os.sep) - baselevel
    offset = level * "../"



More information about the Python-list mailing list