Translating Matlab code to Python
<p>I need to translate chunks of matlab code into Python. My code seems to be 'unreachable' though. Any idea why this is happening? 
Also: am I doing it right? I'm a real newbie.</p>

<p>Matlab code:</p>

<pre><code>function Dir = getScriptDir()
    fullPath = mfilename('fullpath');
    [Dir, ~,~] = fileparts(fullPath);
end

function [list,listSize] = getFileList(Dir)
    DirResult = dir( Dir );
    list = DirResult(~[DirResult.isdir]); % select files
    listSize = size(list);
end
</code></pre>

<p>My Python code: </p>

<pre><code>def Dir = getScriptDir():
    return os.path.dirname(os.path.realpath(__file__)
def getFileList(Dir):
    list = os.listdir(Dir)
    listSize = len(list)
    getFileList() = [list, listSize]
</code></pre>

<p>Your function definitions were incorrect. I have modified the code you provided. You can also consolidate the <code>getScriptDir()</code> functionality into the <code>getFileList()</code> function.</p>

<pre><code>import os

def getFileList():
    dir = os.path.dirname(os.path.realpath(__file__))
    list = os.listdir(dir)
    listSize = len(list)
    fileList = [list, listSize]
    return fileList

print(getFileList())
</code></pre>

<p><strong>Returns: (in my environment)</strong></p>

<pre><code>[['test.py', 'test.txt', 'test2.py', 'test2.txt', 'test3.py', 'test4.py', 'testlog.txt', '__pycache__'], 8]
</code></pre>

<p>Your script functions - including getScriptDir(modified):</p>

<pre><code>import os

def getScriptDir():
    return os.path.dirname(os.path.realpath(__file__))

def getFileList(dir):
    dir = os.path.dirname(os.path.realpath(__file__))
    list = os.listdir(dir)
    listSize = len(list)
    fileList = [list, listSize]
    return fileList


dir = getScriptDir()

print(getFileList(dir))
</code></pre>

python matlab function translation