Reading a list stored in a text file
<p>I have a file whose content is in the form of a python list such as the following: </p>

<pre><code>['hello','how','are','you','doing','today','2016','10.004']
</code></pre>

<p>Is there any way to read the python file back into a list object? instead of using <code>.read()</code> and having the whole file just read as a string.</p>

<p>EDIT: for those who may be interested i ran into a strange issue using (import ast) as suggested as a solution for the above problem. </p>

<p>the program i used it in has a function which fetches historical stock data from the yahoo finance python module. this function is in no way related or dependent on the function which used ast.literal_eval(). </p>

<p>anyways every night after market close i collect new batches of historical data from yahoo finance and last night i ran into an error : simplejson.scanner.jsondecodeerror expecting value. </p>

<p>it was strange because it would collect data just fine for some companies but throw the error for others, and sometime work for the same company but a minute later it would not work.  after trying all kinds of things to debug and solve the issue remembered that the import ast was recently added and thought i should try to see if it could have an effect, after removing the import ast the program went back to workin as it normally did. </p>

<p>does anybody know why import ast caused issues? @Apero why did you initially warn against using eval or ast.literal_eval?</p>