Re: [Tutor] Doubts about Pylint

2008-04-10 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote

>>A = 8
>>az = A
>>
>>It may well be happy since A is a constant and the variable
>>is being assigned the constant rather than the literal.
> 
> Thanks, Alan, but I tried your
> 
> A = 8
> az = A
> 
> and got the same complaint about az.

OK, In that case its probably the fact its global as suggested by 
Jerry and the regex approach being used is assuming all globals 
should be functions or classes or Consts...

The bottom line is that its highlighting something the author 
thought might indicate a problem not necessarily a valid error.

I once used a version of C lint that had a -v flag that printed an 
explanatory message along with each reported error, it would 
be nice if pyLint did the same - a nice wee project for anyone 
that's feeling bored and wants to contribute something to the 
Python/Opensource community maybe?!!! :-)

Alan G

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Doubts about Pylint

2008-04-09 Thread Dick Moores
At 03:15 PM 4/9/2008, Alan Gauld wrote:

>"Dick Moores" <[EMAIL PROTECTED]> wrote
>
> > Since when is 'az' a bad variable name? And 'AZ' is OK?
>
>When it is a constant.
>pyLint sees that you are assigning a numeric literal and
>so thinks that this may be a definition of a constant value.
>
>If you did something like
>
>A = 8
>az = A
>
>It may well be happy since A is a constant and the variable
>is being assigned the constant rather than the literal.

Thanks, Alan, but I tried your

A = 8
az = A

and got the same complaint about az.

Dick



UliPad <>: http://code.google.com/p/ulipad/  

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Doubts about Pylint

2008-04-09 Thread Alan Gauld

"Dick Moores" <[EMAIL PROTECTED]> wrote

> Since when is 'az' a bad variable name? And 'AZ' is OK?

When it is a constant.
pyLint sees that you are assigning a numeroc literal and 
so thinks that this may be a definition of a constant value.

If you disd someting like

A = 8
az = A

It may well be happy since A is a constant and the variable 
is being assigned the constant rather than the literal.

All lint tools are by tradition very exacting, even the C version 
which pyLint is modelled on is notorious for throwing irrelevant 
errors - like not checking the return value of a printf() function 
(printf returns the number of characters printed but virtually 
nobody ever checks that!)

As another poster said treat it in the spirit it is intended, 
a tool to highlight *possible* causes for concern not definite 
causes.


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Doubts about Pylint

2008-04-09 Thread Dick Moores
At 10:14 AM 4/9/2008, Jerry Hill wrote:
>Other than the fact that it's a long list, did *you* have any
>comments?  You present this list like it's a bad thing, but it seems
>to me that pylint is doing exactly what it should.  Do you think that
>there's something wrong with pylint?  Are you just surprised that
>calendar.py doesn't adhere to pylint's coding guidelines?

Yes, I didn't make that clear. See my previous post, which seems to 
have crossed yours.

>1: http://www.logilab.org/card/pylintfeatures
>2: http://www.python.org/dev/peps/pep-0008/

Thanks for these links. Knew about #2, but not #1.

Dick



UliPad <>: http://code.google.com/p/ulipad/ 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Doubts about Pylint

2008-04-09 Thread Dick Moores
At 09:59 AM 4/9/2008, Alex Ezell wrote:
>On Wed, Apr 9, 2008 at 11:43 AM, Dick Moores <[EMAIL PROTECTED]> wrote:
> >  Comments?
>
>Since we started using code profilers and checkers like pyLint etc.,
>we've had a motto:
>
>"This is a guide. It is not the gospel."
>
>Take from pylint what you think helps and ignore the rest. It's just a
>tool and you can choose how to use it.

Your advice is well-taken. But 2 points/puzzlements.
1. Why does Pylint advocate variable names be in all caps? I thought 
I should reserve all caps for indicating a constant..
2. Why is the code in many official Python modules (in Python25\Lib) 
so sloppy by Pylint standards? See those many warnings and errors in 


>That is, unless you want to actually change pylint. I'm sure there's
>opportunity to do that, as well, if you are so inclined.
>
>All that said, your "az" example seems a little silly on pylint's part. :)

Dick Moores




UliPad <>: http://code.google.com/p/ulipad/ 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Doubts about Pylint

2008-04-09 Thread Jerry Hill
On Wed, Apr 9, 2008 at 12:43 PM, Dick Moores <[EMAIL PROTECTED]> wrote:
> I'd never used Pylint until yesterday, when I discovered that Ulipad
>  had a Pylint plugin that enabled me to run Pylint on scripts within
>  Ulipad. But I'm wondering about some of the results. I noticed that
>  it was complaining that my variable names violated convention. Here's
>  an image of running Pylint on a script with only 7 lines:
>  
>
>  Since when is 'az' a bad variable name? And 'AZ' is OK?

Note: I've never used pylint before, so this is all speculation based
on a bit of reading of the pylint web page[1] and PEP 8 [2].

In your code snippet, az is a global variable.  Pylint has a regular
expression that determines if a global variable name matches your
coding convention.  By default, that regex is
(([A-Z_][A-Z1-9_]*)|(__.*__))$.  At a guess, that's because pylint's
author believes the only global variables you should have are
psuedo-constants, and that they should have all uppercase names.  That
seems reasonable to me, if a bit strict.  That particular check does
not line up with the PEP 8 coding conventions, which just suggest that
global variables follow the same naming rules as functions.

I haven't gone through pylint in a lot of detail, but it looks like
most of the other regular expressions are designed to default to the
PEP 8 coding style conventions, or something close to them.  If your
coding conventions are different from the defaults pylint assumes,
you'll probably need to do some setup.

>  And I tried Pylint on an official Python module file, calendar.py.
>  Look what I got when all the checkboxes are
>  checked!!: 
>
>  Comments?

Most of that looks like valid complaints about calendar.py.  The one
exception that jumps out at me is the warning about a relative import
from __future__.  At lot of the other warnings probably depend on the
context.  For instance, the single-character variable names are ugly,
but if they're used inside a loop or a list comprehension they are
probably fine.

Other than the fact that it's a long list, did *you* have any
comments?  You present this list like it's a bad thing, but it seems
to me that pylint is doing exactly what it should.  Do you think that
there's something wrong with pylint?  Are you just surprised that
calendar.py doesn't adhere to pylint's coding guidelines?

1: http://www.logilab.org/card/pylintfeatures
2: http://www.python.org/dev/peps/pep-0008/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Doubts about Pylint

2008-04-09 Thread Eric Walstad
On Wed, Apr 9, 2008 at 9:43 AM, Dick Moores <[EMAIL PROTECTED]> wrote:
> I'd never used Pylint until yesterday
...
>  Since when is 'az' a bad variable name? And 'AZ' is OK?
...
>  Comments?
I understand that Pylint settings and output are *very* customizable.
I seem to remember talk about a PEP['Style Guilde'] config but I don't
know if that ever happened.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Doubts about Pylint

2008-04-09 Thread Alex Ezell
On Wed, Apr 9, 2008 at 11:43 AM, Dick Moores <[EMAIL PROTECTED]> wrote:
>  Comments?

Since we started using code profilers and checkers like pyLint etc.,
we've had a motto:

"This is a guide. It is not the gospel."

Take from pylint what you think helps and ignore the rest. It's just a
tool and you can choose how to use it.

That is, unless you want to actually change pylint. I'm sure there's
opportunity to do that, as well, if you are so inclined.

All that said, your "az" example seems a little silly on pylint's part. :)

/alex
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Doubts about Pylint

2008-04-09 Thread Dick Moores
I'd never used Pylint until yesterday, when I discovered that Ulipad 
had a Pylint plugin that enabled me to run Pylint on scripts within 
Ulipad. But I'm wondering about some of the results. I noticed that 
it was complaining that my variable names violated convention. Here's 
an image of running Pylint on a script with only 7 lines:


Since when is 'az' a bad variable name? And 'AZ' is OK?

And I tried Pylint on an official Python module file, calendar.py. 
Look what I got when all the checkboxes are
checked!!: 

Comments?

Dick Moores


UliPad <>: http://code.google.com/p/ulipad/ 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor