<?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: Is this pylint error message valid or bogus?</title>
	<atom:link href="http://blog.tplus1.com/index.php/2009/06/19/is-this-pylint-error-message-valid-or-bogus/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tplus1.com/index.php/2009/06/19/is-this-pylint-error-message-valid-or-bogus/</link>
	<description>Always looking for interesting problems</description>
	<lastBuildDate>Tue, 09 Mar 2010 10:43:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: lindamoodbell</title>
		<link>http://blog.tplus1.com/index.php/2009/06/19/is-this-pylint-error-message-valid-or-bogus/comment-page-1/#comment-1818</link>
		<dc:creator>lindamoodbell</dc:creator>
		<pubDate>Tue, 30 Jun 2009 06:58:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tplus1.com/?p=372#comment-1818</guid>
		<description>let me give this to my programmer this code, then i can let u know matt</description>
		<content:encoded><![CDATA[<p>let me give this to my programmer this code, then i can let u know matt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Kirby</title>
		<link>http://blog.tplus1.com/index.php/2009/06/19/is-this-pylint-error-message-valid-or-bogus/comment-page-1/#comment-1777</link>
		<dc:creator>Dave Kirby</dc:creator>
		<pubDate>Sat, 20 Jun 2009 14:37:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tplus1.com/?p=372#comment-1777</guid>
		<description>I agree with the commenters on clp - as a user of the function looking at the signature, I would expect that initial_time needed to be a string.   &lt;br&gt;&lt;br&gt;If you wanted to use something more explicit than None, then you could use a placeholder object, e.g.&lt;br&gt;&lt;br&gt;TODAY = object()&lt;br&gt;def midnight_next_day(initial_time=TODAY):&lt;br&gt;    if initial_time is TODAY:&lt;br&gt;    ...&lt;br&gt;&lt;br&gt;however pylint still complains that instance of object does not have a date method.</description>
		<content:encoded><![CDATA[<p>I agree with the commenters on clp &#8211; as a user of the function looking at the signature, I would expect that initial_time needed to be a string.   </p>
<p>If you wanted to use something more explicit than None, then you could use a placeholder object, e.g.</p>
<p>TODAY = object()<br />def midnight_next_day(initial_time=TODAY):<br />    if initial_time is TODAY:<br />    &#8230;</p>
<p>however pylint still complains that instance of object does not have a date method.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Finney</title>
		<link>http://blog.tplus1.com/index.php/2009/06/19/is-this-pylint-error-message-valid-or-bogus/comment-page-1/#comment-1772</link>
		<dc:creator>Ben Finney</dc:creator>
		<pubDate>Sat, 20 Jun 2009 00:19:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tplus1.com/?p=372#comment-1772</guid>
		<description>&gt; The vast majority of pythoners use None, but I prefer descriptive strings for default values&lt;br&gt;&lt;br&gt;If you do that, you&#039;re communicating badly.&lt;br&gt;&lt;br&gt;Python&#039;s default arguments mean something very specific, and readers will expect it: “this argument can be omitted, and if so, *this value will be used instead*”. By putting a value there that you never intend on using, you subvert that communication.&lt;br&gt;&lt;br&gt;Please, if you don&#039;t have a good static value to use, just stick with the conventional sentinel value: None.&lt;br&gt;&lt;br&gt;If you need None for some other purpose (e.g. you need to tell the difference between the default and a user-supplied None), use a clearly-for-no-other-purpose object, such as a module-local name bound to a unique object() instance.</description>
		<content:encoded><![CDATA[<p>&gt; The vast majority of pythoners use None, but I prefer descriptive strings for default values</p>
<p>If you do that, you&#39;re communicating badly.</p>
<p>Python&#39;s default arguments mean something very specific, and readers will expect it: “this argument can be omitted, and if so, *this value will be used instead*”. By putting a value there that you never intend on using, you subvert that communication.</p>
<p>Please, if you don&#39;t have a good static value to use, just stick with the conventional sentinel value: None.</p>
<p>If you need None for some other purpose (e.g. you need to tell the difference between the default and a user-supplied None), use a clearly-for-no-other-purpose object, such as a module-local name bound to a unique object() instance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: D&#39;gou</title>
		<link>http://blog.tplus1.com/index.php/2009/06/19/is-this-pylint-error-message-valid-or-bogus/comment-page-1/#comment-1769</link>
		<dc:creator>D&#39;gou</dc:creator>
		<pubDate>Fri, 19 Jun 2009 21:45:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tplus1.com/?p=372#comment-1769</guid>
		<description>Nicely refactored.&lt;br&gt;&quot;Gordian knot? What gordian knot? Just a bunch of pieces of rope on the floor here.&quot; :)</description>
		<content:encoded><![CDATA[<p>Nicely refactored.<br />&#8220;Gordian knot? What gordian knot? Just a bunch of pieces of rope on the floor here.&#8221; <img src='http://blog.tplus1.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gary Bernhardt</title>
		<link>http://blog.tplus1.com/index.php/2009/06/19/is-this-pylint-error-message-valid-or-bogus/comment-page-1/#comment-1768</link>
		<dc:creator>Gary Bernhardt</dc:creator>
		<pubDate>Fri, 19 Jun 2009 20:45:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tplus1.com/?p=372#comment-1768</guid>
		<description>I&#039;d turn it into two functions: midnight_tomorrow() and midnight_after(initial_date). Default arguments tell you that you&#039;re probably violating the SRP. (Or maybe they&#039;re *always* violations; I haven&#039;t thought enough about it yet.) Here&#039;s a version with two functions:&lt;br&gt;&lt;br&gt;def midnight_tomorrow():&lt;br&gt;....return midnight_after(datetime.now())&lt;br&gt;&lt;br&gt;def midnight_after(initial_time):&lt;br&gt;....return initial_time.date() + timedelta(days=1)&lt;br&gt;&lt;br&gt;There are no conditionals needed, it&#039;s two eloc instead of three, and there&#039;s less thinking required by the guy who calls these functions. The caller doesn&#039;t need the docstring suggested above by Alex or the descriptive default value you used; the functions&#039; names are fully self-descriptive.</description>
		<content:encoded><![CDATA[<p>I&#39;d turn it into two functions: midnight_tomorrow() and midnight_after(initial_date). Default arguments tell you that you&#39;re probably violating the SRP. (Or maybe they&#39;re *always* violations; I haven&#39;t thought enough about it yet.) Here&#39;s a version with two functions:</p>
<p>def midnight_tomorrow():<br />&#8230;.return midnight_after(datetime.now())</p>
<p>def midnight_after(initial_time):<br />&#8230;.return initial_time.date() + timedelta(days=1)</p>
<p>There are no conditionals needed, it&#39;s two eloc instead of three, and there&#39;s less thinking required by the guy who calls these functions. The caller doesn&#39;t need the docstring suggested above by Alex or the descriptive default value you used; the functions&#39; names are fully self-descriptive.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nes</title>
		<link>http://blog.tplus1.com/index.php/2009/06/19/is-this-pylint-error-message-valid-or-bogus/comment-page-1/#comment-1767</link>
		<dc:creator>nes</dc:creator>
		<pubDate>Fri, 19 Jun 2009 20:25:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tplus1.com/?p=372#comment-1767</guid>
		<description>code does not come out that nice on the comment. Let&#039;s try this instead:&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://pastebin.com/m19049702&quot; rel=&quot;nofollow&quot;&gt;http://pastebin.com/m19049702&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>code does not come out that nice on the comment. Let&#39;s try this instead:</p>
<p><a href="http://pastebin.com/m19049702" rel="nofollow">http://pastebin.com/m19049702</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nes</title>
		<link>http://blog.tplus1.com/index.php/2009/06/19/is-this-pylint-error-message-valid-or-bogus/comment-page-1/#comment-1766</link>
		<dc:creator>nes</dc:creator>
		<pubDate>Fri, 19 Jun 2009 20:20:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tplus1.com/?p=372#comment-1766</guid>
		<description>pylint thinks initial_time might be a string sometimes.&lt;br&gt;&lt;br&gt;&gt;&gt;&gt; def midnight_next_day(initial_time=&quot;use today&#039;s date&quot;):&lt;br&gt;&lt;br&gt;     if initial_time == &quot;use today&#039;s  date&quot;:&lt;br&gt;        initial_time = datetime.now()&lt;br&gt;&lt;br&gt;     return initial_time.date() + timedelta(days=1)&lt;br&gt;&lt;br&gt;&gt;&gt;&gt; midnight_next_day()&lt;br&gt;&lt;br&gt;Traceback (most recent call last):&lt;br&gt;  File &quot;&lt;pyshell#24&gt;&quot;, line 1, in &lt;module&gt;&lt;br&gt;    midnight_next_day()&lt;br&gt;  File &quot;&lt;pyshell#23&gt;&quot;, line 6, in midnight_next_day&lt;br&gt;    return initial_time.date() + timedelta(days=1)&lt;br&gt;AttributeError: &#039;str&#039; object has no attribute &#039;date&#039;&lt;br&gt;&gt;&gt;&gt;</description>
		<content:encoded><![CDATA[<p>pylint thinks initial_time might be a string sometimes.</p>
<p>&gt;&gt;&gt; def midnight_next_day(initial_time=&#8221;use today&#39;s date&#8221;):</p>
<p>     if initial_time == &#8220;use today&#39;s  date&#8221;:<br />        initial_time = datetime.now()</p>
<p>     return initial_time.date() + timedelta(days=1)</p>
<p>&gt;&gt;&gt; midnight_next_day()</p>
<p>Traceback (most recent call last):<br />  File &#8220;&lt;pyshell#24&gt;&#8221;, line 1, in &lt;module&gt;<br />    midnight_next_day()<br />  File &#8220;&lt;pyshell#23&gt;&#8221;, line 6, in midnight_next_day<br />    return initial_time.date() + timedelta(days=1)<br />AttributeError: &#39;str&#39; object has no attribute &#39;date&#39;<br />&gt;&gt;&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://blog.tplus1.com/index.php/2009/06/19/is-this-pylint-error-message-valid-or-bogus/comment-page-1/#comment-1765</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Fri, 19 Jun 2009 19:16:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tplus1.com/?p=372#comment-1765</guid>
		<description>Sorry, but that&#039;s so nasty. Just use None and provide the description as a comment or in the docstring, please. None exists for a reason.</description>
		<content:encoded><![CDATA[<p>Sorry, but that&#39;s so nasty. Just use None and provide the description as a comment or in the docstring, please. None exists for a reason.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://blog.tplus1.com/index.php/2009/06/19/is-this-pylint-error-message-valid-or-bogus/comment-page-1/#comment-1764</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Fri, 19 Jun 2009 19:16:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tplus1.com/?p=372#comment-1764</guid>
		<description>there is no need for an if statement:&lt;br&gt;&lt;br&gt;initial_time = intial_time or datatime.now()&lt;br&gt;&lt;br&gt;the original version is bad because it suggests that your functions is taking string parameters, where in fact it takes datetime objects. Misleading.</description>
		<content:encoded><![CDATA[<p>there is no need for an if statement:</p>
<p>initial_time = intial_time or datatime.now()</p>
<p>the original version is bad because it suggests that your functions is taking string parameters, where in fact it takes datetime objects. Misleading.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
