How to convert ast.Tuple to a list
<p>I tried to convert an ast.Tuple into a list by doing this</p>

<pre><code>mylist = list(mytuple)
</code></pre>

<p>However, I am getting a <code>Tuple object is not iterable</code> error. Is there a way to convert this tuple into a list?</p>

<p>The tuple in question is a <code>Tuple</code> of <code>ast</code> objects, one being type <code>ast.Str</code>, the other being <code>ast.Name</code>. My ultimate goal is to create a string of the two. However, there might be situations where there are more than two elements in the tuple so I need to be able to iterate over the tuple to check what type of <code>ast</code> object each element is.</p>

<p>This is the error message from the python interpreter</p>

<pre><code>TypeError: 'Tuple' object is not iterable
</code></pre>

<p>This is the code that produced the error</p>

<pre><code>if type(foo) is ast.Tuple:
    g = list(foo)
</code></pre>