is there a way to do range() with ast.literal_eval?
<p>or another way to ask I suppose is there a literal which will literal_eval to the equivalent of the range function (without sending the entire array as a range).</p>

<p>the following</p>

<pre><code>import ast
ast.literal_eval("range(0,3)")
ast.literal_eval("[0, 1, 2, 3][0:3]")
</code></pre>

<p>results in:</p>

<pre><code>Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "/usr/lib64/python2.7/ast.py", line 80, in literal_eval
    return _convert(node_or_string)
  File "/usr/lib64/python2.7/ast.py", line 79, in _convert
    raise ValueError('malformed string')
ValueError: malformed string
</code></pre>

<p>while this is possible it converts the entire array to a string then back which is not ideal.  I was hoping for something with [0:3] syntax without the initial list.</p>

<pre><code>&gt;&gt;&gt; ast.literal_eval(str(range(0,3)))
[0, 1, 2]
</code></pre>
