<?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: I want your awesome python snippets.</title>
	<atom:link href="http://jessenoller.com/2009/12/19/i-want-your-awesome-python-snippets/feed/" rel="self" type="application/rss+xml" />
	<link>http://jessenoller.com/2009/12/19/i-want-your-awesome-python-snippets/</link>
	<description>python, programming and other things</description>
	<lastBuildDate>Sun, 04 Mar 2012 06:06:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jon</title>
		<link>http://jessenoller.com/2009/12/19/i-want-your-awesome-python-snippets/comment-page-1/#comment-139151</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Wed, 06 Jan 2010 08:57:07 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/?p=734#comment-139151</guid>
		<description>This will be ridiculous to most people, but I&#039;ve been programming professionally in Python for a year and a half and only figured this out today...&lt;br&gt;&lt;br&gt;instead of (when overriding a method to add kwargs...)&lt;br&gt;&lt;br&gt;def foo(self, **kwargs):&lt;br&gt;    if &quot;foobar&quot; in kwargs:&lt;br&gt;        self.foobar = kwargs[&quot;foobar&quot;]&lt;br&gt;        del(kwargs[&quot;foobar&quot;])&lt;br&gt;    else:&lt;br&gt;        self.foobar = None&lt;br&gt;    super(Foo, self).foo(**kwargs)&lt;br&gt;&lt;br&gt;do&lt;br&gt;&lt;br&gt;def foo(self, **kwargs):&lt;br&gt;    self.foobar = kwargs.pop(&quot;foobar&quot;, None)&lt;br&gt;    super(Foo, self).foo(**kwargs)</description>
		<content:encoded><![CDATA[<p>This will be ridiculous to most people, but I’ve been programming professionally in Python for a year and a half and only figured this out today…</p>
<p>instead of (when overriding a method to add kwargs…)</p>
<p>def foo(self, **kwargs):<br />    if “foobar” in kwargs:<br />        self.foobar = kwargs[“foobar”]<br />        del(kwargs[“foobar”])<br />    else:<br />        self.foobar = None<br />    super(Foo, self).foo(**kwargs)</p>
<p>do</p>
<p>def foo(self, **kwargs):<br />    self.foobar = kwargs.pop(“foobar”, None)<br />    super(Foo, self).foo(**kwargs)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://jessenoller.com/2009/12/19/i-want-your-awesome-python-snippets/comment-page-1/#comment-137082</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Wed, 06 Jan 2010 02:57:07 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/?p=734#comment-137082</guid>
		<description>This will be ridiculous to most people, but I&#039;ve been programming professionally in Python for a year and a half and only figured this out today...&lt;br&gt;&lt;br&gt;instead of (when overriding a method to add kwargs...)&lt;br&gt;&lt;br&gt;def foo(self, **kwargs):&lt;br&gt;    if &quot;foobar&quot; in kwargs:&lt;br&gt;        self.foobar = kwargs[&quot;foobar&quot;]&lt;br&gt;        del(kwargs[&quot;foobar&quot;])&lt;br&gt;    else:&lt;br&gt;        self.foobar = None&lt;br&gt;    super(Foo, self).foo(**kwargs)&lt;br&gt;&lt;br&gt;do&lt;br&gt;&lt;br&gt;def foo(self, **kwargs):&lt;br&gt;    self.foobar = kwargs.pop(&quot;foobar&quot;, None)&lt;br&gt;    super(Foo, self).foo(**kwargs)</description>
		<content:encoded><![CDATA[<p>This will be ridiculous to most people, but I’ve been programming professionally in Python for a year and a half and only figured this out today…</p>
<p>instead of (when overriding a method to add kwargs…)</p>
<p>def foo(self, **kwargs):<br />    if “foobar” in kwargs:<br />        self.foobar = kwargs[“foobar”]<br />        del(kwargs[“foobar”])<br />    else:<br />        self.foobar = None<br />    super(Foo, self).foo(**kwargs)</p>
<p>do</p>
<p>def foo(self, **kwargs):<br />    self.foobar = kwargs.pop(“foobar”, None)<br />    super(Foo, self).foo(**kwargs)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joso S. O. Bueno</title>
		<link>http://jessenoller.com/2009/12/19/i-want-your-awesome-python-snippets/comment-page-1/#comment-136886</link>
		<dc:creator>Joso S. O. Bueno</dc:creator>
		<pubDate>Mon, 04 Jan 2010 12:08:07 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/?p=734#comment-136886</guid>
		<description># a bit washed out, but should fulfill the &quot;acessible&quot; part while retaining some wonder&lt;br&gt;# with the zip and enumerate calls. &lt;br&gt;&lt;br&gt;# (I have some oneliner obfuscated versions of this, but I don&#039;t think those are the goal :-)  )&lt;br&gt;&lt;br&gt;def romans_to_numerals(roman_str):&lt;br&gt;__ roman_digits = &quot;IVXLCDM&quot;&lt;br&gt;__ numeric_values = (1, 5, 10, 50, 100, 500, 1000)&lt;br&gt;__ values = dict(zip(roman_digits, numeric_values))&lt;br&gt;__ final_value = 0&lt;br&gt;__ for i, digit in enumerate(roman_str):&lt;br&gt;____ final_value += values[digit]&lt;br&gt;____ if i &gt; 0 and roman_digits.index(roman_str[i - 1]) &lt; roman_digits.index(digit):&lt;br&gt;______ final_value -= 2 * values[roman_str[i - 1]]&lt;br&gt;__ return final_value</description>
		<content:encoded><![CDATA[<p># a bit washed out, but should fulfill the “acessible” part while retaining some wonder<br /># with the zip and enumerate calls. </p>
<p># (I have some oneliner obfuscated versions of this, but I don’t think those are the goal :-)  )</p>
<p>def romans_to_numerals(roman_str):<br />__ roman_digits = “IVXLCDM“<br />__ numeric_values = (1, 5, 10, 50, 100, 500, 1000)<br />__ values = dict(zip(roman_digits, numeric_values))<br />__ final_value = 0<br />__ for i, digit in enumerate(roman_str):<br />____ final_value += values[digit]<br />____ if i &gt; 0 and roman_digits.index(roman_str[i — 1]) &lt; roman_digits.index(digit):<br />______ final_value -= 2 * values[roman_str[i — 1]]<br />__ return final_value</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Siddharth Mitra</title>
		<link>http://jessenoller.com/2009/12/19/i-want-your-awesome-python-snippets/comment-page-1/#comment-136824</link>
		<dc:creator>Siddharth Mitra</dc:creator>
		<pubDate>Sun, 03 Jan 2010 21:48:59 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/?p=734#comment-136824</guid>
		<description>Neat python tricks - &lt;a href=&quot;http://bit.ly/79CND9&quot; rel=&quot;nofollow&quot;&gt;http://bit.ly/79CND9&lt;/a&gt; on reddit and on Stackoverflow - &lt;a href=&quot;http://bit.ly/6qmAum&quot; rel=&quot;nofollow&quot;&gt;http://bit.ly/6qmAum&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Neat python tricks — <a href="http://bit.ly/79CND9" rel="nofollow">http://bit.ly/79CND9</a> on reddit and on Stackoverflow — <a href="http://bit.ly/6qmAum" rel="nofollow">http://bit.ly/6qmAum</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roger Pate</title>
		<link>http://jessenoller.com/2009/12/19/i-want-your-awesome-python-snippets/comment-page-1/#comment-136723</link>
		<dc:creator>Roger Pate</dc:creator>
		<pubDate>Sat, 02 Jan 2010 22:32:04 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/?p=734#comment-136723</guid>
		<description>While there&#039;s some controversy around Community Wiki questions on Stack Overflow (I notice you have an account), this seems to be exactly appropriate.  One suggestion: state a time limit in the question after which you&#039;ll close it, otherwise it will accumulate duplicates and other cruft.</description>
		<content:encoded><![CDATA[<p>While there’s some controversy around Community Wiki questions on Stack Overflow (I notice you have an account), this seems to be exactly appropriate.  One suggestion: state a time limit in the question after which you’ll close it, otherwise it will accumulate duplicates and other cruft.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roger Pate</title>
		<link>http://jessenoller.com/2009/12/19/i-want-your-awesome-python-snippets/comment-page-1/#comment-136624</link>
		<dc:creator>Roger Pate</dc:creator>
		<pubDate>Sat, 02 Jan 2010 06:20:31 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/?p=734#comment-136624</guid>
		<description>__all__ = []&lt;br&gt;def export(obj):&lt;br&gt;  __all__.append(obj.__name__)&lt;br&gt;  return obj&lt;br&gt;&lt;br&gt;@export&lt;br&gt;class Example: pass&lt;br&gt;&lt;br&gt;@export&lt;br&gt;def example(): pass</description>
		<content:encoded><![CDATA[<p>__all__ = []<br />def export(obj):<br />  __all__.append(obj.__name__)<br />  return obj</p>
<p>@export<br />class Example: pass</p>
<p>@export<br />def example(): pass</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pkarl</title>
		<link>http://jessenoller.com/2009/12/19/i-want-your-awesome-python-snippets/comment-page-1/#comment-136234</link>
		<dc:creator>pkarl</dc:creator>
		<pubDate>Wed, 30 Dec 2009 22:58:47 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/?p=734#comment-136234</guid>
		<description>&lt;a href=&quot;http://snipt.net/pkarl/return-a-string-starting-wthe-last-occurrence-of/&quot; rel=&quot;nofollow&quot;&gt;http://snipt.net/pkarl/return-a-string-starting...&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p><a href="http://snipt.net/pkarl/return-a-string-starting-wthe-last-occurrence-of/" rel="nofollow"></a><a href="http://snipt.net/pkarl/return-a-string-starting" rel="nofollow">http://snipt.net/pkarl/return-a-string-starting</a>…</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chin</title>
		<link>http://jessenoller.com/2009/12/19/i-want-your-awesome-python-snippets/comment-page-1/#comment-135997</link>
		<dc:creator>chin</dc:creator>
		<pubDate>Mon, 28 Dec 2009 10:25:41 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/?p=734#comment-135997</guid>
		<description>Recursive generation of binary digits&lt;br&gt;&lt;br&gt;def iinc(n):&lt;br&gt;   if n &lt;= 0: return [0]&lt;br&gt;   res = iinc(n-1)&lt;br&gt;   stack = res[:]&lt;br&gt;   while stack:&lt;br&gt;       k = stack.pop()&lt;br&gt;       if k: res[len(stack)] = 0&lt;br&gt;       else: res[len(stack)] = 1; return res&lt;br&gt;   return [1] + res</description>
		<content:encoded><![CDATA[<p>Recursive generation of binary digits</p>
<p>def iinc(n):<br />   if n &lt;= 0: return [0]<br />   res = iinc(n-1)<br />   stack = res[:]<br />   while stack:<br />       k = stack.pop()<br />       if k: res[len(stack)] = 0<br />       else: res[len(stack)] = 1; return res<br />   return [1] + res</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kenneth Reitz</title>
		<link>http://jessenoller.com/2009/12/19/i-want-your-awesome-python-snippets/comment-page-1/#comment-134932</link>
		<dc:creator>Kenneth Reitz</dc:creator>
		<pubDate>Mon, 21 Dec 2009 18:40:51 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/?p=734#comment-134932</guid>
		<description>&lt;a href=&quot;http://github.com/kennethreitz/kenlib&quot; rel=&quot;nofollow&quot;&gt;http://github.com/kennethreitz/kenlib&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p><a href="http://github.com/kennethreitz/kenlib" rel="nofollow">http://github.com/kennethreitz/kenlib</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mario</title>
		<link>http://jessenoller.com/2009/12/19/i-want-your-awesome-python-snippets/comment-page-1/#comment-134777</link>
		<dc:creator>Mario</dc:creator>
		<pubDate>Sun, 20 Dec 2009 07:31:57 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/?p=734#comment-134777</guid>
		<description>Take a look at my blog (&lt;a href=&quot;http://pysnippet.com&quot; rel=&quot;nofollow&quot;&gt;pysnippet.com&lt;/a&gt;). I have some posts about file-like objects, unit-testing, and language features such as the with-statement and for/while/try-else.</description>
		<content:encoded><![CDATA[<p>Take a look at my blog (<a href="http://pysnippet.com" rel="nofollow">pysnippet.com</a>). I have some posts about file-like objects, unit-testing, and language features such as the with-statement and for/while/try-else.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Object Caching 725/725 objects using disk: basic

Served from: jessenoller.com @ 2012-05-22 08:45:17 -->
