python return empty list from function
<p>I am sorry to ask such a basic question but I am trying to learn python and don't understand why this does not work. When I run this program on a directory it prints and empty list []. I don't understand why. Can someone help? Python 3.</p>

<pre><code>import sys, os, 



def getfiles(currdir):
    myfiles = []
    for file in os.listdir(currdir):
         for file in os.listdir(currdir):
            path = os.path.join(currdir,file)
            if not os.path.isdir(path):
                myfiles.append(path)
            else:
                getfiles(path)
    return(myfiles)




if __name__ == '__main__':
    filedirectory = []
    filedirectory = getfiles(sys.argv[1])
    print(filedirectory)
</code></pre>

<p>This returns []</p>

<p>Thank you for the help</p>

<p>If i understand you want to get all of the file names in a specific directory. here is my code to do that :</p>

<pre><code>Import os
AllFiles = []
AllFiles = os.listdir("your Directory")
</code></pre>

<p>listdir() return all files name in the specific directory.</p>

python