pylint -- should I just ignore it sometimes?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Fri Oct 22 04:12:41 EDT 2010


On Thu, 21 Oct 2010 17:20:54 +0200, Jean-Michel Pichavant wrote:

> While I totally understand why some ppl prefer to use short names, 

Oh the irony.

> I
> really don't see the point in saying that because any information can be
> wrong, we should stop giving any.

It's only in your fevered imagination that people are saying that. Nobody 
says that we should stop giving *any*.

Words gain their meaning from convention and common usage. There is 
nothing about the word "car" that suggests a metal and plastic mechanical 
transportation device that people sit in and travel across bitumen or 
asphalt roads, it is only common usage that makes it so.

There's nothing about the word "sales_total" that means the sum of the 
numeric sales figures for some given time period. It is only common usage 
that makes it so.

Some words are shorter than others. In English, the noun "I" is a single 
letter, but it has a known meaning. In French so does the word "y". 
Spanish also has a word "y", but it's not the same word. A word doesn't 
cease to have meaning just because it is short.

Common programming usage makes it that a variable called "i" usually 
means a generic integer, especially if it represents an index. Common 
usage makes it that a variable called "s" is a generic string. If you 
flout these conventions, and write code like this:

def prepend(d, i):
    """Return string d with string i prepended to it."""
    if not (isinstance(d, str) and isinstance(i, str)):
        raise TypeError("expected two string arguments")
    return i + d

then people will rightly laugh at you for misusing common names. And if 
you pay no attention to these conventions, and write:

def prepend(string_to_be_prepended_to, string_to_prepend):
    ...

people will *also* laugh at you for being needlessly verbose. The 
sensible middle-ground would be something like this:

def prepend(s, prefix):
    """Return string s with prefix prepended to it."""
    if not (isinstance(s, str) and isinstance(prefix, str)):
        raise TypeError("expected two string arguments")
    return prefix + s

although I wouldn't mind if you used "string" instead of "s". Both would 
be acceptable to me.



-- 
Steven



More information about the Python-list mailing list