title: Regular expression to find function calls in a file with Python regular expression?
body: <p>I would like a regular expression, of which I will use with the Python re module, that will look for python function calls within a python file, but there will be caveats around the function calls that I'm looking for.</p>
  
  <ul>
  <li>The function calls will have a single, specific name.</li>
  <li>The function calls may be chained, but will only have one chained call that will always have the same name.</li>
  <li>The first function will always take a single string argument.</li>
  <li>The chained function, however, might take arbitrary arguments (this is the one that worries me).</li>
  </ul>
  
  <p>Here are example usages of the functions I want to look for within a file:</p>
  
  <pre><code># Simple function call.
  f("_key")
  
  # The chained function call, in the simplest format (no args).
  f("_key").g()
  
  # The chained function call with simple arguments.
  f("_key").g("hello", 1337)
  
  # The chained function call with possible, more complex arguments
  f("_key").g(obj.blah(), {"dog":"cat"})
  
  # And then the possibility for long function calls to extend over one line
  f("_key").g(
              "dogs",
              "cats",
              {"living":"together"})
  </code></pre>
  
  <p>And the usual disclaimer: I did a search for this, and the questions were close to mine, but I'm wondering if my needs are constrained enough to get around the "regular vs. irregular" language problem. This is what I get for not being a computer science major and being afraid of regular expressions.</p>