Is this pylint error message valid or silly?
rhodri at wildebst.demon.co.uk
Fri Jun 19 15:53:57 CEST 2009
On Fri, 19 Jun 2009 14:36:01 +0100, Matthew Wilson <matt at tplus1.com> wrote:
> On Fri 19 Jun 2009 02:55:52 AM EDT, Terry Reedy wrote:
>>> if c == "today":
>>> c = datetime.today()
>> Now I guess that you actually intend c to be passed as a datetime
>> object. You only used the string as a type annotation, not as a real
>> default value. Something like 'record_date = None' is better.
> Thanks for the feedback. I think I should have used a more obvious
> string in my original example and a more descriptive parameter name.
> So, pretend that instead of
> I wrote
> record_date="defaults to today's date".
> I know my way is unorthodox, but I think it is a little bit more obvious
> to the reader than
> The None is a signal to use a default value, but that is only apparent
> after reading the code.
It's a very common idiom, however, and in addition
record_data is None
is a cheap test, while
record_data == "defaults to today's date"
is an expensive test as well as easy to mistype.
Rhodri James *-* Wildebeest Herder to the Masses
More information about the Python-list