title: Determine if function includes a specific method
body: <p>I would like to write some code to check student submissions to ensure that a given function includes <code>np.random.choice</code>.</p>
  <p>For example:</p>
  <pre><code>import numpy as np
  
  def checkme(z, x=[1,2,3], y=4):
    tmp = np.random.choice(x, size=y)
    if z:
      print(&quot;z&quot;)
    return(list(tmp))
  </code></pre>
  <p>I have seen that I can use calls like</p>
  <pre><code>tmp = inspect.signature(checkme)
  for param in tmp.parameters.values():
    print(param.name, &quot;,&quot;, param.default)
  </code></pre>
  <p>To determine the parameters and values, which is great, but I want to take this one step further and ensure that the body of the function included a specific function or method.  So above, I would want to ensure the students' code included <code>np.random.choice</code>.</p>
  <p>How can I access the body of the function to &quot;inspect&quot; and determine if this is True or False?</p>