Is this pylint error message valid or silly?

Aahz aahz at pythoncraft.com
Sat Jun 20 00:17:50 EDT 2009


In article <87eitg267e.fsf at benfinney.id.au>,
Ben Finney  <ben+python at benfinney.id.au> wrote:
>Matthew Wilson <matt at tplus1.com> writes:
>>
>>     from datetime import datetime
>>     def f(c="today"):
>>         if c == "today":
>>                     c = datetime.today()
>>         return c.date()
>
>* You're re-binding the parameter name ‘c’ to something different within
>  the function: it starts out bound to the input string, but by the time
>  the function ends you're expecting it to be bound to a datetime
>  object. Instead, you should be binding a *different* name to the
>  datetime object you create inside the function, and using that for the
>  return statement.

Actually, I disagree that this is necessarily bad, although it's often a
yellow flag.  The context in which it is possibly appropriate is when you
want your function to handle multiple types for one parameter and you
always cast the data to one single type.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"as long as we like the same operating system, things are cool." --piranha



More information about the Python-list mailing list