<br><br><div><span class="gmail_quote">On 10/27/07, <b class="gmail_sendername">John</b> &lt;<a href="mailto:washakie@gmail.com">washakie@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>The problem is the infies are also being used in a shell scripted environment, they are frequently updated and cannot be changed.</div>
<div>&nbsp;</div>
<div>So ideadly I could just define a function which sourced the file, assuming the variable names passed in the *args list. So, yes, I know the names, they just haven&#39;t been set in the program. I would like the source program to then define them. My re is not so great, but I&#39;m assuming the statement here:
</div><span class="q">
<div>&nbsp;</div>
<div><font face="Courier New">cmd = &#39;\n&#39;.join([re.sub( r&#39;^([^=]+)=(.*)$&#39;, r&quot;\1=&#39;\2&#39;&quot;, v) for v in lines])</font><br>&nbsp;</div></span>
<div>assumes the pattern VAR[i]=variable , and then makes it Python friendly.</div>
<div>&nbsp;</div>
<div>So it would look like:</div>
<div>&nbsp;</div>
<div>my_source(fid,[&#39;STN_id&#39;,&#39;STNlat&#39;,&#39;STNlon&#39;,&#39;STNelv&#39;])</div>
<div>&nbsp;</div>
<div>then in the program, before exec(cmd) the *args list has to be converted into empy lists, preparing it for the cmd. Does that make sense?? </div>
<div>&nbsp;</div>
<div>Thanks!</div>
<div>&nbsp;</div>
</blockquote></div><div><br class="webkit-block-placeholder"></div><div>the re expression just changes &quot;lvalue=rvalue&quot; to &quot;lvalue=&#39;rvalue&#39;&quot;. It doesn&#39;t know whether lvalue is array or something else.
</div><div><br class="webkit-block-placeholder"></div><div>Anyway, you&nbsp;can initialize the variables as follows -</div><div><br>for v in [&#39;STN_id&#39;, ... ] :</div><div><div>&nbsp;&nbsp; exec( &#39;global %s ; %s = [0]*5&#39; % (v, v))
</div><div><br class="webkit-block-placeholder"></div><div>Unfortunately these variable need to be made global for them to be visible everywhere.<br clear="all"><br>&nbsp;</div><div>HTH&nbsp;<br>Aditya
</div></div>