<div>Here's where I am:</div>
<div> </div>
<div>
<p><font face="courier new,monospace">def source(filename, vList):<br> """ takes a file object and a list of variables as input """<br> import re<br> # Read the file<br> fid=open(filename,'r')
<br> lines = fid.readlines()<br> fid.close()<br> #how many variables<br> ns=len(lines)/len(vList)<br> #predefine the varibles<br> for v in vList:<br> exec( 'global %s ; %s = [0]*(ns+1)' % (v, v))<br> <br> # Make it python friendly: put all values in 'single quotes'
<br> cmd = '\n'.join([re.sub( r'^([^=]+)=(.*)$', r"\1='\2'", v) for v in lines])<br> exec(cmd)<br> for v in vList:<br> exec( '%s=%s[1:]' % (v,v))<br> <br>source('infile.py',['files','nfiles','nreleases'])
</font></p>
<p><font face="courier new,monospace">print files<br>print nreleases<br>print nfiles</font></p>
<p><font face="Courier New"></font> </p>
<p><font face="Courier New">But oddly, my output is:</font></p>
<p>[0, 'ASP_200603', 'ASP_200604', 'ASP_200605']<br>[0, '248', '240', '248']<br>[0, '3', '3', '3']</p>
<p> </p>
<p>So, I am not properly getting rid of the list[0], is it something with the 'global' nature of the vairables... it looks like it's only changing locallly in my source function.<br></p></div>