Parse External Methods Calls Within Python Function?
<p>Given the python code:</p>

<pre><code>import sys
import os 

def MyPythonMethod(value1, value2):
    # defining some variables 
    a = 4
    myValue = 15.65
    listValues = [4, 67, 83, -23]

    # check if a file exists
    if ( os.path.exists('/home/hello/myfile.txt') ):
        pass

    # doing some operation on the list
    listValues[0] = listValues[1]       

    # check if a file exists
    print sys.path

    # looping through the values
    for i in listValues:
        print i 
</code></pre>

<p>How can I extract the <code>names</code> of all external methods in function <code>MyPythonMethod</code>?</p>

<p>Ideally, I'd like to get a list of all external methods/members that are being invoked. </p>

<p>For <code>MyPythonMethod</code>, this will return:</p>

<p><code>moduleNames = ["os", "sys"]</code></p>

<p><code>methodsInvoked = ["os.path.exists", "sys.path"]</code></p>

<p>(yes, I know that 'path' is a member of <code>sys</code>, not a method; but I think you get the idea).</p>

<p>Any ideas?</p>
