Python Style Guide Questions - Contd.

Marc 'BlackJack' Rintsch bj_666 at
Mon Jan 19 22:32:10 CET 2009

On Mon, 19 Jan 2009 05:50:54 -0800, koranthala wrote:

> Hi,
>    I have some more questions about python code styling. 1. Global
>    Variables: In my code, I am using some global variables.
> Now, when I ran PyLint, it raised convention errors mentioning that they
> should be CAPITAL_ALPHABETS. Now, in PEP 8, I did not see that
> mentioned. Please let me know whether that is the usual styling
> mechanism which is used.

PEP8 doesn't mention constants at all.  The all caps naming for constants 
is a convention in several languages.

>    2. I have many loops wherein I define a variable as just a counter.
>        for x in range(counter):
>           do_something()
>        Please note that I am not using x anywhere in the program. Pylint
>        again raises warnings saying that the variable should be
> used.
>        Should I disregard it or use the default variable _ ? for _ in
>        range(counter):
>           do_something()
>        pylint does not raise errors for those. Are there any issues in
> using _ ?

Pylint doesn't barf on `dummy` either.  The point is having a name that 
makes clear at the head of the loop, that the reader doesn't have to 
bother looking for places where the value will be used because it is 
clear from the name that the value won't be used at all.

BTW pylint is very configurable, you can dump the default configuration 
and find out which names are "allowed" by default and of course define 
your own set of "value doesn't matter" names.

	Marc 'BlackJack' Rintsch

More information about the Python-list mailing list