How to view variables within a function when warning is thrown pdb in python?
<p>Im running into a problem where</p>

<pre><code>cds_to_protein = str(feature.extract(record).seq.translate(to_stop = True))
</code></pre>

<p>will throw a Biopython warning.  So I need to see what record and feature is being passed to it that causes that warning.</p>

<p>Is there a way to use pdb or another debugger to view parameters within a function?</p>

<p>EDIT: I'm using <code>python -Werror -m pdb script.py</code> which works to stop pdb when the warning appears</p>

<p>I've also added</p>

<pre><code>    saved_record = record
    saved_feature = feature
</code></pre>

<p>in order to save them but I don't know if they're necessary.  Should I make them global in order to view them?</p>

<p>Here's the function:</p>

<pre><code>def validate_cds(record, feature):

    saved_record = record
    saved_feature = feature

    protein_in_file = str(feature.qualifiers.get('translation', 'no_translation')).strip('\'[]')

    cds_to_protein = str(feature.extract(record).seq.translate(to_stop = True))

    return
</code></pre>

<p>Per the <a href="https://docs.python.org/2/library/pdb.html" rel="nofollow">docs</a>:</p>

<blockquote>
  <p>The typical usage to break into the debugger from a running program is to insert</p>
</blockquote>

<p><code>import pdb; pdb.set_trace()</code></p>

<blockquote>
  <p>at the location you want to break into the debugger. You can then step through the code following this statement, and continue running without the debugger using the c command.</p>
</blockquote>

python python-2.7 biopython