<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Another ten essential Python tips</title>
	<atom:link href="http://www.linuxuser.co.uk/tutorials/another-ten-essential-python-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.linuxuser.co.uk/tutorials/another-ten-essential-python-tips/</link>
	<description></description>
	<lastBuildDate>Wed, 08 Feb 2012 13:04:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: anon</title>
		<link>http://www.linuxuser.co.uk/tutorials/another-ten-essential-python-tips/comment-page-1/#comment-47762</link>
		<dc:creator>anon</dc:creator>
		<pubDate>Sun, 11 Sep 2011 03:48:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.linuxuser.co.uk/?p=1018#comment-47762</guid>
		<description>just came across a link to few free python book. very useful for python beginners
http://cmdlinetips.com/2011/09/free-python-books-online/</description>
		<content:encoded><![CDATA[<p>just came across a link to few free python book. very useful for python beginners<br />
<a href="http://cmdlinetips.com/2011/09/free-python-books-online/" rel="nofollow">http://cmdlinetips.com/2011/09/free-python-books-online/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Another ten essential Python tips &#124; Linux User &#124; Errors &#38; Geeks</title>
		<link>http://www.linuxuser.co.uk/tutorials/another-ten-essential-python-tips/comment-page-1/#comment-2671</link>
		<dc:creator>Another ten essential Python tips &#124; Linux User &#124; Errors &#38; Geeks</dc:creator>
		<pubDate>Sat, 20 Feb 2010 08:25:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.linuxuser.co.uk/?p=1018#comment-2671</guid>
		<description>[...] the rest here:  Another ten essential Python tips &#124; Linux User   Tags: backup, features, linux, linux-user, networks, news, open-source, PHP, Python, security, [...]</description>
		<content:encoded><![CDATA[<p>[...] the rest here:  Another ten essential Python tips | Linux User   Tags: backup, features, linux, linux-user, networks, news, open-source, PHP, Python, security, [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lawrence D’Oliveiro</title>
		<link>http://www.linuxuser.co.uk/tutorials/another-ten-essential-python-tips/comment-page-1/#comment-2657</link>
		<dc:creator>Lawrence D’Oliveiro</dc:creator>
		<pubDate>Fri, 19 Feb 2010 06:58:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.linuxuser.co.uk/?p=1018#comment-2657</guid>
		<description>Removing duplicates: do it in one line using sets, not dictionaries:

&gt;&gt;&gt; l = (1, 2, 2, 3, 4)
&gt;&gt;&gt; l
(1, 2, 2, 3, 4)
&gt;&gt;&gt; type(l)(set(l))
(1, 2, 3, 4)
&gt;&gt;&gt; l = [3, 4, 3, 5, 6]
&gt;&gt;&gt; l
[3, 4, 3, 5, 6]
&gt;&gt;&gt; type(l)(set(l))
[3, 4, 5, 6]</description>
		<content:encoded><![CDATA[<p>Removing duplicates: do it in one line using sets, not dictionaries:</p>
<p>&gt;&gt;&gt; l = (1, 2, 2, 3, 4)<br />
&gt;&gt;&gt; l<br />
(1, 2, 2, 3, 4)<br />
&gt;&gt;&gt; type(l)(set(l))<br />
(1, 2, 3, 4)<br />
&gt;&gt;&gt; l = [3, 4, 3, 5, 6]<br />
&gt;&gt;&gt; l<br />
[3, 4, 3, 5, 6]<br />
&gt;&gt;&gt; type(l)(set(l))<br />
[3, 4, 5, 6]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lawrence D’Oliveiro</title>
		<link>http://www.linuxuser.co.uk/tutorials/another-ten-essential-python-tips/comment-page-1/#comment-2656</link>
		<dc:creator>Lawrence D’Oliveiro</dc:creator>
		<pubDate>Fri, 19 Feb 2010 06:57:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.linuxuser.co.uk/?p=1018#comment-2656</guid>
		<description>What do you think your “gc” example is achieving? It’s only referencing the functions, not calling them. I think you want empty parentheses “()” after each function name, to indicate you’re calling them.</description>
		<content:encoded><![CDATA[<p>What do you think your “gc” example is achieving? It’s only referencing the functions, not calling them. I think you want empty parentheses “()” after each function name, to indicate you’re calling them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gwb</title>
		<link>http://www.linuxuser.co.uk/tutorials/another-ten-essential-python-tips/comment-page-1/#comment-2621</link>
		<dc:creator>gwb</dc:creator>
		<pubDate>Wed, 17 Feb 2010 14:37:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.linuxuser.co.uk/?p=1018#comment-2621</guid>
		<description>nope. didn&#039;t work</description>
		<content:encoded><![CDATA[<p>nope. didn&#8217;t work</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gwb</title>
		<link>http://www.linuxuser.co.uk/tutorials/another-ten-essential-python-tips/comment-page-1/#comment-2620</link>
		<dc:creator>gwb</dc:creator>
		<pubDate>Wed, 17 Feb 2010 14:36:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.linuxuser.co.uk/?p=1018#comment-2620</guid>
		<description>the problem with the white space seems to be a problem of the site&#039;s handling of data. Dunno if it supports pre-formatted tags.  Let&#039;s try:


 this
   is
      indented
</description>
		<content:encoded><![CDATA[<p>the problem with the white space seems to be a problem of the site&#8217;s handling of data. Dunno if it supports pre-formatted tags.  Let&#8217;s try:</p>
<p> this<br />
   is<br />
      indented</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick</title>
		<link>http://www.linuxuser.co.uk/tutorials/another-ten-essential-python-tips/comment-page-1/#comment-2613</link>
		<dc:creator>Rick</dc:creator>
		<pubDate>Wed, 17 Feb 2010 03:19:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.linuxuser.co.uk/?p=1018#comment-2613</guid>
		<description>Since white space is significant in python, several of the code examples need to be cleaned up.</description>
		<content:encoded><![CDATA[<p>Since white space is significant in python, several of the code examples need to be cleaned up.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: paul</title>
		<link>http://www.linuxuser.co.uk/tutorials/another-ten-essential-python-tips/comment-page-1/#comment-2609</link>
		<dc:creator>paul</dc:creator>
		<pubDate>Wed, 17 Feb 2010 00:49:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.linuxuser.co.uk/?p=1018#comment-2609</guid>
		<description>Removing duplicates from lists can be done a lot easier with set. E.g.:

&gt;&gt;&gt; l = [1,2,2,3,4,4,5]
&gt;&gt;&gt; set(l)
set([1, 2, 3, 4, 5])</description>
		<content:encoded><![CDATA[<p>Removing duplicates from lists can be done a lot easier with set. E.g.:</p>
<p>&gt;&gt;&gt; l = [1,2,2,3,4,4,5]<br />
&gt;&gt;&gt; set(l)<br />
set([1, 2, 3, 4, 5])</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom K</title>
		<link>http://www.linuxuser.co.uk/tutorials/another-ten-essential-python-tips/comment-page-1/#comment-2607</link>
		<dc:creator>Tom K</dc:creator>
		<pubDate>Tue, 16 Feb 2010 20:55:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.linuxuser.co.uk/?p=1018#comment-2607</guid>
		<description>I think you want to complEment the other collections of tips, not complIment them.</description>
		<content:encoded><![CDATA[<p>I think you want to complEment the other collections of tips, not complIment them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gwb</title>
		<link>http://www.linuxuser.co.uk/tutorials/another-ten-essential-python-tips/comment-page-1/#comment-2606</link>
		<dc:creator>gwb</dc:creator>
		<pubDate>Tue, 16 Feb 2010 20:18:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.linuxuser.co.uk/?p=1018#comment-2606</guid>
		<description>The example of removing dups from a list can also be done with set semantics:

newlist = list(set(oldlist))

Note that both this approach and the original one will destroy the order of the elements.  If you want to preserve order, something like this would do it:

def unique(list_):
 s = set()
 newl = []
 for x in list_:
   if x not in s:
     new.append(x)
     s.add(x)
 return newl

You could even be tricksy with something like this:

listset = set()
newlist = list(x for x in oldlist if x not in listset and not listset.add(x))

since set().add() returns None which is boolean False so &quot;not set().add()&quot; will always be true. However, this method involves redundant calls to set().add().</description>
		<content:encoded><![CDATA[<p>The example of removing dups from a list can also be done with set semantics:</p>
<p>newlist = list(set(oldlist))</p>
<p>Note that both this approach and the original one will destroy the order of the elements.  If you want to preserve order, something like this would do it:</p>
<p>def unique(list_):<br />
 s = set()<br />
 newl = []<br />
 for x in list_:<br />
   if x not in s:<br />
     new.append(x)<br />
     s.add(x)<br />
 return newl</p>
<p>You could even be tricksy with something like this:</p>
<p>listset = set()<br />
newlist = list(x for x in oldlist if x not in listset and not listset.add(x))</p>
<p>since set().add() returns None which is boolean False so &#8220;not set().add()&#8221; will always be true. However, this method involves redundant calls to set().add().</p>
]]></content:encoded>
	</item>
</channel>
</rss>

