Dear Tutors,<br><br>I have a text file (mylist.py actually), it contains exactly below:<br>---------------<br># file mylist.py<br>jobs = [<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;Lions&#39;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;SysTest&#39;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;trainDD&#39;,
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;Cats&#39;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;train&#39;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;sharks&#39;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;whale&#39;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ]<br>----------------<br><br>I want to write another script and get the list &quot;jobs&quot; from the above script.
<br><br>Is it possible for me to get the variable &#39;jobs&#39; and its value from the file (as a list)? What I&#39;m trying to do now is open the file, readlines in a loop, once it finds the line with &quot;jobs = [&quot;, then start accumulate (append) a varible until it hits the line with &quot;]&quot; then stop. This is too complicated. I believe there should be an easier way in Python. Can anyone guide me, please.
<br><br>Thanks in advance,<br>PB<br><br>