Dear Tutors,<br><br>I have a text file (mylist.py actually), it contains exactly below:<br>---------------<br># file mylist.py<br>jobs = [<br> 'Lions',<br> 'SysTest',<br> 'trainDD',
<br> 'Cats',<br> 'train',<br> 'sharks',<br> 'whale',<br> ]<br>----------------<br><br>I want to write another script and get the list "jobs" from the above script.
<br><br>Is it possible for me to get the variable 'jobs' and its value from the file (as a list)? What I'm trying to do now is open the file, readlines in a loop, once it finds the line with "jobs = [", then start accumulate (append) a varible until it hits the line with "]" 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>