Getting a dict out of a method?
<p>I'm trying to get a <code>dict</code> out of a method, so far I'm able to get the method name, and its arguments (using the inspect module), the problem I'm facing is that I'd like to have the default arguments too (or the argument type).</p>

<p>This is basically my unit test:</p>

<pre><code>class Test:
    def method1(anon_type, array=[], string="string", integer=12, obj=None):
        pass

target = {"method1": [
             {"anon": "None"}, 
             {"array": "[]"}, 
             {"string": "str"}, 
             {"integer": "int"},
             {"obj": "None"}]
         }
method1_dict = get_method_dict(Test().method1)

self.assertEqual(target, method1_dict)
</code></pre>

<p>Here, I try to use <em>inspect</em> to get the method:</p>

<pre><code>&gt;&gt;&gt; import inspect
&gt;&gt;&gt; class Class:
...     def method(self, string='str', integer=12):
...             pass
... 
&gt;&gt;&gt; m_desc = inspect.getargspec(Class().method)
&gt;&gt;&gt; m_desc
ArgSpec(args=['self', 'string', 'integer'], varargs=None, keywords=None, defaults=('str', 12))
&gt;&gt;&gt;
</code></pre>

<p>but my problem is with the <em>default args</em>, as you see here:</p>

<pre><code>&gt;&gt;&gt; class Class:
...     def method(self, no_def_args, string='str', integer=12):
...             pass
... 
&gt;&gt;&gt; m_desc = inspect.getargspec(Class().method)
&gt;&gt;&gt; m_desc
ArgSpec(args=['self', 'no_def_args', 'string', 'integer'], varargs=None, keywords=None, defaults=('str', 12))
</code></pre>

<p>As you see the <code>no_def_args</code> is not in the defaults, so it's a problem to try to match the argument with their default arguments.</p>
