Python: os.path.isdir /isfile /exists not working, returning False when they should return True
<p>So, here is my little program. It should print all files in a given directory + all files in every subdirectory.</p>

<pre><code>import os

def listFiles(directory):
    dirList = os.listdir(directory)
    printList = []
    for i in dirList:
        i = os.path.join(directory,i)
      #  print(i)
        if os.path.isdir(i):
            printList[len(dirList):] = listFiles(i)
        else:
            printList.append(i)
    return printList

directory = 'C:\Python32\Lib'
listFiles(directory)
a = listFiles(directory)

for i in a:
    print(i)
</code></pre>

<p>What's the problem: os.path.isdir(i) isn't working properly - for example, if I try</p>

<pre><code>os.path.isfile('C:\Python32\Lib\concurrent\futures\process.py')
os.path.exists('C:\Python32\Lib\concurrent\futures\process.py')
os.path.isdir('C:\Python32\Lib\concurrent\futures')
</code></pre>

<p>I always get False instead of True (it works ok for some of the subdirectories). If I uncomment print(i) it prints everything just fine but it also prints directories - I want just to print files. What should I do?</p>
