You can merge those into:

    for p in dirs + files

(or use something other than os.walk)