<div class="gmail_quote">On Mon, Oct 11, 2010 at 12:10 PM,  <span dir="ltr">&lt;<a href="mailto:aeneas24@priest.com">aeneas24@priest.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<font color="black" size="2" face="arial">
<div><font face="Arial, Helvetica, sans-serif"></font>&lt;snip&gt;</div>


<div> </div>


<div>rgenre = re.split(r&#39;;&#39;, <a href="http://rf.info" target="_blank">rf.info</a>[&quot;genre&quot;] if &quot;genre&quot; in <a href="http://rf.info" target="_blank">rf.info</a> else []</div>


<div> </div>


<div>I get a syntax error at &quot;if&quot; in 2.4.3.</div></font></blockquote><div><br></div><div>That&#39;s because you&#39;re using the ternary operator that was not available in 2.4: <a href="http://www.python.org/dev/peps/pep-0308/">http://www.python.org/dev/peps/pep-0308/</a></div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><font color="black" size="2" face="arial"><div> </div>


<div> </div>


<div>I tried doing the following but it doesn&#39;t work (I don&#39;t understand why). </div>


<blockquote style="margin-right:0px" dir="ltr"><div>if &quot;genre&quot; in <a href="http://rf.info" target="_blank">rf.info</a>:<br>
          rgenre = re.split(r&#39;;&#39;, <a href="http://rf.info" target="_blank">rf.info</a>[&quot;genre&quot;])<br>
else:<br>
          []</div>


<div> </div>
</blockquote>

<div>And I tried this, too: </div>


<div> </div>

<blockquote style="margin-right:0px" dir="ltr">

<div>if &quot;genre&quot; in <a href="http://rf.info" target="_blank">rf.info</a>:<br>
          rgenre = re.split(r&#39;;&#39;, <a href="http://rf.info" target="_blank">rf.info</a>[&quot;genre&quot;])<br>
if &quot;genre&quot; not in <a href="http://rf.info" target="_blank">rf.info</a>:<br>
          []</div>
</blockquote>

<div dir="ltr">Both of these cause problems later on in the program, specifically &quot;UnboundLocalError: local variable &#39;rgenre&#39; referenced before assignment&quot;, about this line in the code (where each of these is one of the 30 possible genres):</div>

</font></blockquote><div><br></div><div>The problem isn&#39;t with your logic expression - it&#39;s because on the else case you never assign anything to rgenre, you simply state &#39;empty list&#39; - not &#39;set rgenre to be an empty list&#39;.</div>

<div><br></div><div>if &#39;genre&#39; in <a href="http://rf.info">rf.info</a>:</div><div>    rgenre = re.split(r&#39;;&#39;, <a href="http://rf.info">rf.info</a>[&#39;genre&#39;])</div><div>else:</div><div>    rgenre = []</div>

<div><br></div><div>will work on all(?) versions of python - and 2.4 certainly.</div><div><br></div><div>HTH,</div><div>Wayne</div></div>