<div><br></div><div>Hi,</div><div><div><br></div><div>I would like to get the list of parameters I need to initialize an AST node.</div><div><br></div><div>I'm trying to use the `inspect` module, however it seems I can't use it on a built-in (native?) class, or else I misunderstood. </div>

<div><br></div><div>I'm using Python 2.7 and tried with Python 3.2.</div><div><br></div><div>This is working:</div><div><br></div><div>    >>> import inspect</div><div>    >>> class C:</div><div>    ...     def __init__(a,b=4):</div>

<div>    ...         self.sum = a + b</div><div>    ... </div><div>    >>> inspect.getargspec(C.__init__)</div><div>    ArgSpec(args=['a', 'b'], varargs=None, keywords=None, defaults=(4,))</div><div>

<br></div><div>This is not working:</div><div><br></div><div>    >>> import inspect</div><div>    >>> import ast</div><div>    >>> inspect.getargspec(ast.If.__init__)</div><div>    Traceback (most recent call last):</div>

<div>      File "<stdin>", line 1, in <module></div><div>      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 813, in getargspec</div><div>        raise TypeError('{!r} is not a Python function'.format(func))</div>

<div>    TypeError: <slot wrapper '__init__' of '_ast.AST' objects> is not a Python function</div></div><div><br></div><div>I am wondering if there is another way to get these parameters automatically? (ie. without compiling myself a dict) </div>

<div><br></div>Regards,<br clear="all"><div><div>J. Bilcke</div><div><br></div></div>