how to print type of keys for a list in python pdb
<p>I'm learning pdb and I can print, or pp a list of objects but how can I print the type of key for each object?  I can see it with pp, it looks like a byte array but I'd like to know the type.  I suppose I could just print debug this but I'm curious if there's a smarter way to do it when using the debugger.</p>

<p>Because you wrote</p>

<blockquote>
  <p>type of key</p>
</blockquote>

<p>I'm assuming that you mean a dictionary. But you <em>do</em> also talk about a "list of objects", which could also mean</p>

<ul>
<li>a list of any kind of object</li>
<li>a list of dictionaries</li>
</ul>

<p>But I'll show you two options:</p>

<pre><code>mydict = {b'some bytes': 42,
          'a string!': 'fnord',
          (1,2,3): 'A tuple! (is that two-pull or tuh-ple?)',
          19: 'Just an int',
          }

list_of_things = [b'some bytes', 'a string!', (1,2,3), 19, ['a', 'b', 'c']]

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

<p>Now when <code>pdb</code> fires up:</p>

<pre><code>(Pdb) for _ in mydict: print('{} {}'.format(_, type(_)))
19 &lt;type 'int'&gt;
some bytes &lt;type 'str'&gt;
a string! &lt;type 'str'&gt;
(1, 2, 3) &lt;type 'tuple'&gt;
</code></pre>

<p>That will give you the keys and types of the keys.</p>

<p>Here's the types and values from the list:</p>

<pre><code>(Pdb) for _ in list_of_things: print('{} {}'.format(_, type(_)))
some bytes &lt;type 'str'&gt;
a string! &lt;type 'str'&gt;
(1, 2, 3) &lt;type 'tuple'&gt;
19 &lt;type 'int'&gt;
['a', 'b', 'c'] &lt;type 'list'&gt;
</code></pre>

python pdb