<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>t+1 - Latest Comments in Is this pylint error message valid or bogus?</title><link>http://tplus1.disqus.com/</link><description></description><atom:link href="https://tplus1.disqus.com/is_this_pylint_error_message_valid_or_bogus/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Sat, 20 Jun 2009 09:37:38 -0000</lastBuildDate><item><title>Re: Is this pylint error message valid or bogus?</title><link>http://blog.tplus1.com/blog/2009/06/19/is-this-pylint-error-message-valid-or-bogus/#comment-11499112</link><description>&lt;p&gt;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;/p&gt;&lt;p&gt;If you wanted to use something more explicit than None, then you could use a placeholder object, e.g.&lt;/p&gt;&lt;p&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;/p&gt;&lt;p&gt;however pylint still complains that instance of object does not have a date method.&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dave Kirby</dc:creator><pubDate>Sat, 20 Jun 2009 09:37:38 -0000</pubDate></item><item><title>Re: Is this pylint error message valid or bogus?</title><link>http://blog.tplus1.com/blog/2009/06/19/is-this-pylint-error-message-valid-or-bogus/#comment-11487245</link><description>&lt;p&gt;&amp;gt; The vast majority of pythoners use None, but I prefer descriptive strings for default values&lt;/p&gt;&lt;p&gt;If you do that, you're communicating badly.&lt;/p&gt;&lt;p&gt;Python'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;/p&gt;&lt;p&gt;Please, if you don't have a good static value to use, just stick with the conventional sentinel value: None.&lt;/p&gt;&lt;p&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.&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ben Finney</dc:creator><pubDate>Fri, 19 Jun 2009 19:19:24 -0000</pubDate></item><item><title>Re: Is this pylint error message valid or bogus?</title><link>http://blog.tplus1.com/blog/2009/06/19/is-this-pylint-error-message-valid-or-bogus/#comment-11482203</link><description>&lt;p&gt;Nicely refactored.&lt;br&gt;"Gordian knot? What gordian knot? Just a bunch of pieces of rope on the floor here." :)&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">D'gou</dc:creator><pubDate>Fri, 19 Jun 2009 16:45:04 -0000</pubDate></item><item><title>Re: Is this pylint error message valid or bogus?</title><link>http://blog.tplus1.com/blog/2009/06/19/is-this-pylint-error-message-valid-or-bogus/#comment-11479844</link><description>&lt;p&gt;I'd turn it into two functions: midnight_tomorrow() and midnight_after(initial_date). Default arguments tell you that you're probably violating the SRP. (Or maybe they're *always* violations; I haven't thought enough about it yet.) Here's a version with two functions:&lt;/p&gt;&lt;p&gt;def midnight_tomorrow():&lt;br&gt;....return midnight_after(&lt;a href="http://datetime.now" rel="nofollow noopener" target="_blank" title="datetime.now"&gt;datetime.now&lt;/a&gt;())&lt;/p&gt;&lt;p&gt;def midnight_after(initial_time):&lt;br&gt;....return &lt;a href="http://initial_time.date" rel="nofollow noopener" target="_blank" title="initial_time.date"&gt;initial_time.date&lt;/a&gt;() + timedelta(days=1)&lt;/p&gt;&lt;p&gt;There are no conditionals needed, it's two eloc instead of three, and there's less thinking required by the guy who calls these functions. The caller doesn't need the docstring suggested above by Alex or the descriptive default value you used; the functions' names are fully self-descriptive.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Gary Bernhardt</dc:creator><pubDate>Fri, 19 Jun 2009 15:45:16 -0000</pubDate></item><item><title>Re: Is this pylint error message valid or bogus?</title><link>http://blog.tplus1.com/blog/2009/06/19/is-this-pylint-error-message-valid-or-bogus/#comment-11479033</link><description>&lt;p&gt;code does not come out that nice on the comment. Let's try this instead:&lt;/p&gt;&lt;p&gt;&lt;a href="http://pastebin.com/m19049702" rel="nofollow noopener" target="_blank" title="http://pastebin.com/m19049702"&gt;http://pastebin.com/m19049702&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nes</dc:creator><pubDate>Fri, 19 Jun 2009 15:25:18 -0000</pubDate></item><item><title>Re: Is this pylint error message valid or bogus?</title><link>http://blog.tplus1.com/blog/2009/06/19/is-this-pylint-error-message-valid-or-bogus/#comment-11478834</link><description>&lt;p&gt;pylint thinks initial_time might be a string sometimes.&lt;/p&gt;&lt;p&gt;&amp;gt;&amp;gt;&amp;gt; def midnight_next_day(initial_time="use today's date"):&lt;/p&gt;&lt;p&gt;     if initial_time == "use today's  date":&lt;br&gt;        initial_time = &lt;a href="http://datetime.now" rel="nofollow noopener" target="_blank" title="datetime.now"&gt;datetime.now&lt;/a&gt;()&lt;/p&gt;&lt;p&gt;     return &lt;a href="http://initial_time.date" rel="nofollow noopener" target="_blank" title="initial_time.date"&gt;initial_time.date&lt;/a&gt;() + timedelta(days=1)&lt;/p&gt;&lt;p&gt;&amp;gt;&amp;gt;&amp;gt; midnight_next_day()&lt;/p&gt;&lt;p&gt;Traceback (most recent call last):&lt;br&gt;  File "&amp;lt;pyshell#24&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;br&gt;    midnight_next_day()&lt;br&gt;  File "&amp;lt;pyshell#23&amp;gt;", line 6, in midnight_next_day&lt;br&gt;    return &lt;a href="http://initial_time.date" rel="nofollow noopener" target="_blank" title="initial_time.date"&gt;initial_time.date&lt;/a&gt;() + timedelta(days=1)&lt;br&gt;AttributeError: 'str' object has no attribute 'date'&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nes</dc:creator><pubDate>Fri, 19 Jun 2009 15:20:42 -0000</pubDate></item><item><title>Re: Is this pylint error message valid or bogus?</title><link>http://blog.tplus1.com/blog/2009/06/19/is-this-pylint-error-message-valid-or-bogus/#comment-11460289</link><description>&lt;p&gt;Sorry, but that's so nasty. Just use None and provide the description as a comment or in the docstring, please. None exists for a reason.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alex</dc:creator><pubDate>Fri, 19 Jun 2009 14:16:50 -0000</pubDate></item><item><title>Re: Is this pylint error message valid or bogus?</title><link>http://blog.tplus1.com/blog/2009/06/19/is-this-pylint-error-message-valid-or-bogus/#comment-11460263</link><description>&lt;p&gt;there is no need for an if statement:&lt;/p&gt;&lt;p&gt;initial_time = intial_time or &lt;a href="http://datatime.now" rel="nofollow noopener" target="_blank" title="datatime.now"&gt;datatime.now&lt;/a&gt;()&lt;/p&gt;&lt;p&gt;the original version is bad because it suggests that your functions is taking string parameters, where in fact it takes datetime objects. Misleading.&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Fri, 19 Jun 2009 14:16:13 -0000</pubDate></item></channel></rss>