Sorry for the formatting. Added return statements to both functions. Adding return [x, y] to get_value func. That solved the problem. Thank you! :)<div><br></div><div>Saad<br><br>On Thursday, February 23, 2012, Alan Gauld  wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 23/02/12 00:59, Saad Javed wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
[CODE]feed = urllib.urlopen(rssPage) #rssPage: address of xml feed<br>
tree = etree.parse(feed)<br>
x = tree.xpath(&quot;/rss/channel/item/<u></u>title/text()&quot;)<br>
x = str(x[0])<br>
for tag in tags: #tags is a list of items like hdtv, xvid, 720p etc<br>
x = re.sub(r&#39;\b&#39; + tag + r&#39;\b&#39;, &#39;&#39;, x)<br>
z = re.sub(r&#39;[^\w\s]&#39;, &#39;&#39;, x)<br>
y = tree1.xpath(&quot;/rss/channel/<u></u>item/pubDate/text()&quot;)<br>
print &quot;%s - %s&quot; %(z.rstrip(), y[0][:16])[/CODE]<br>
</blockquote>
<br>
Please don;t insert wiki style markers, its just confusing.<br>
Also please use plain text for email otherwise the formatting<br>
tends to get lost.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
[CODE]def get_value(feed):<br>
try:<br>
url = urllib2.urlopen(feed)<br>
tree = etree.parse(url)<br>
x = tree.xpath(&quot;/rss/channel/item/<u></u>title/text()&quot;)<br>
y = tree.xpath(&quot;/rss/channel/item/<u></u>pubDate/text()&quot;)<br>
x = str(x[0])<br>
y = str(y[0][:16])<br>
return x<br>
return y<br>
</blockquote>
<br>
This will always return x and never y because a return statement terminates the function. If you want to return both values you need to put them in the same return statement:<br>
<br>
return x,y<br>
<br>
If you want to return only one you need to select which<br>
with an if/else.<br>
<br>
return x if &lt;some condition&gt; else y<br>
<br>
or just<br>
<br>
if &lt;some condition&gt;<br>
   return x<br>
else<br>
   return y<br>
<br>
If you prefer.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
except SyntaxError:<br>
</blockquote>
<br>
You should probably not try catching Syntax errors since thats usually a fault in your code! Instead fix the syntax error.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
def del_tag(x):<br>
tags = [&#39;HDTV&#39;, &#39;LOL&#39;, &#39;VTV&#39;, &#39;x264&#39;, &#39;DIMENSION&#39;, &#39;XviD&#39;, &#39;720P&#39;,<br>
&#39;IMMERSE&#39;, &#39;720p&#39;, &#39;X264&#39;]<br>
for tag in tags:<br>
x = re.sub(r&#39;\b&#39; + tag + r&#39;\b&#39;, &#39;&#39;, x)<br>
y = re.sub(r&#39;[^\w\s]&#39;, &#39;&#39;, x)<br>
</blockquote>
<br>
You don&#39;t return x or y so they get thrown away at the end of the function. Which makes the whole thing a waste of space...<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
def main():<br>
a = get_value(rssPage)<br>
b = del_tag(a)<br>
print b<br>
if __name__ == &#39;__main__&#39;:<br>
main()[/CODE]<br>
<br>
Running this code returns [B]None[/B].<br>
</blockquote>
<br>
None is the default return value if you do not provide one.<br>
main has no return statement. Neither does del_tag()<br>
Both main and del_tag will therefore return None.<br>
<br>
HTH<br>
-- <br>
Alan G<br>
Author of the Learn to Program web site<br>
<a href="http://www.alan-g.me.uk/" target="_blank">http://www.alan-g.me.uk/</a><br>
<br>
______________________________<u></u>_________________<br>
Tutor maillist  -  <a>Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/tutor</a><br>
</blockquote></div>