472,791 Members | 1,490 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 software developers and data experts.

PEP 8 style enforcing program

Some recent posts about Python programming style got me thinking.
Since we have the PEP 8 which gives some guidelines about the style to
be used, do we have any program that can check for violations of these
guidelines within the source code? I understand that there are a lot
of code beautifiers out there, but i haven't seen one specially
tailored for Python... Is there even a desire in Python community for
a program like this (by Python community I mean the people in this
group:) ) ? I think it would be a nice little project for practice and
I'd like to do it, but if there is already something like this then I
can probably spend my time on something more productive. So, I'd like
to hear your opinion on this...
There is one thing that I don't understand about PEP 8 - why is using
spaces considered more desirable than using tabs for indentation?

May 31 '07 #1
7 1742
mo*********@gmail.com schrieb:
Some recent posts about Python programming style got me thinking.
Since we have the PEP 8 which gives some guidelines about the style to
be used, do we have any program that can check for violations of these
guidelines within the source code? I understand that there are a lot
of code beautifiers out there, but i haven't seen one specially
tailored for Python... Is there even a desire in Python community for
a program like this (by Python community I mean the people in this
group:) ) ? I think it would be a nice little project for practice and
I'd like to do it, but if there is already something like this then I
can probably spend my time on something more productive. So, I'd like
to hear your opinion on this...
There is one thing that I don't understand about PEP 8 - why is using
spaces considered more desirable than using tabs for indentation?
Pylint is one of them (http://www.logilab.org/857)

With spaces you get always the same len of the line, where tabs can use 2,4,8
spaces, dependingt on the settings of the IDE

Alexander
May 31 '07 #2
montyphyton wrote this on Thu, 31 May 2007 05:16:30 -0700. My reply
is below.
I understand that there are a lot of code beautifiers out there, but
i haven't seen one specially tailored for Python.
Consider PythonTidy:

o http://lacusveris.com/PythonTidy/PythonTidy.python

--
... Chuck Rhode, Sheboygan, WI, USA
... Weather: http://LacusVeris.com/WX
... 75° — Wind SSE 9 mph — Sky haze.
May 31 '07 #3
Alexander Eisenhuth wrote:
Pylint is one of them (http://www.logilab.org/857)
BTW: Why does pylint want all names with underscores? I tested it
and it complains about malformed names in e.g. the following cases
that are conformant to PEP 8:

- single letter as parameter
- firstLowerCamelCase names for instances and instance methods in
class declarations ("should match [a-z_][a-z0-9_]{2,30}$")
- all lowercase method names in class declarations

Those policies are barely usable, IMHO, and neither practical.

LOL, and it rates my code -1.9/10. The minus is no typo.

Regards,
Björn

--
BOFH excuse #291:

Due to the CDA, we no longer have a root account.

May 31 '07 #4
On 5/31/07, Bjoern Schliessmann
<us**************************@spamgourmet.comwrote :
Alexander Eisenhuth wrote:
Pylint is one of them (http://www.logilab.org/857)

BTW: Why does pylint want all names with underscores? I tested it
and it complains about malformed names in e.g. the following cases
that are conformant to PEP 8:

- single letter as parameter
This seems to be an Logilab internal restriction.
- firstLowerCamelCase names for instances and instance methods in
class declarations ("should match [a-z_][a-z0-9_]{2,30}$")
- all lowercase method names in class declarations
No. Quoting PEP 8:
Functions:
"""
mixedCase is allowed only in contexts where that's already the
prevailing style (e.g. threading.py), to retain backwards compatibility.
"""
Methods and instances:
"""
Use the function naming rules: lowercase with words separated by
underscores as necessary to improve readability.
"""

Those policies are barely usable, IMHO, and neither practical.
I Desagree.

--
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
May 31 '07 #5
Eduardo "EdCrypt" O. Padoan wrote:
No. Quoting PEP 8:
Functions:
"""
mixedCase is allowed only in contexts where that's already the
prevailing style (e.g. threading.py), to retain backwards
compatibility.
"""
Methods and instances:
"""
Use the function naming rules: lowercase with words separated by
underscores as necessary to improve readability.
"""
Has this been updated recently? I could've sworn I had read that
stuff like has_key was "old".

Regards,
Björn

--
BOFH excuse #432:

Borg nanites have infested the server

May 31 '07 #6
Bjoern Schliessmann wrote:
Eduardo "EdCrypt" O. Padoan wrote:
>No. Quoting PEP 8:
Functions:
"""
mixedCase is allowed only in contexts where that's already the
prevailing style (e.g. threading.py), to retain backwards
compatibility.
"""
Methods and instances:
"""
Use the function naming rules: lowercase with words separated by
underscores as necessary to improve readability.
"""

Has this been updated recently? I could've sworn I had read that
stuff like has_key was "old".
You can check the revision history here:

http://svn.python.org/view/peps/trun...55405&view=log

Looks to me like camelCase became unacceptable in Revision 1781, back in
March 2004.

STeVe
Jun 1 '07 #7
In <5c*************@mid.individual.net>, Bjoern Schliessmann wrote:
[ripped out of context :-)]
Has this been updated recently? I could've sworn I had read that
stuff like has_key was "old".
Yes, `has_key()` is "old", it's spelled ``in`` these days. :-)

if mapping.has_key(ham): pass

# ->

if ham in mapping: pass

Ciao,
Marc 'BlackJack' Rintsch
Jun 1 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Xamle Eng | last post by:
I am looking for a data oriented schema-enforcing XML editor. By schema-enforcing I mean an editor that doesn't just have a button to verify the schema - I want an editor that actively enforces it...
14
by: Daniel Billingsley | last post by:
I'm always curious on some of these style issues if there seem to actually be objective reasons for doing things one way or the other, so here goes for a little lighter discussion. 1) Default...
29
by: Ron Burd | last post by:
Hi, As my company is moving into C# they are enforcing the use of styling convention in the source code, such as methods naming conventions, newlines, etc. Does someone know of products that...
2
by: Frosty | last post by:
Howto make datagrid enforce rules of xml schema? Created xml schema in the designer. Constraints created there using the following <xs:simpleType name="zipcode"><xs:restriction...
1
by: David Johnson | last post by:
I am using Forms Authentication. What is best practice of enforcing each user to only be permitted to run a single instance of the application. I would like to enforce this even if the...
18
by: Joel Hedlund | last post by:
Hi! The question of type checking/enforcing has bothered me for a while, and since this newsgroup has a wealth of competence subscribed to it, I figured this would be a great way of learning...
10
by: ddtbhai | last post by:
Hello folks, Just wanted to know if there are some 'standard' approaches to enforcing an order in the invocation of calling functions. It is usually needed when initializing some object. e.g...
4
by: Mark McIntyre | last post by:
Hallvard B Furuseth wrote: Setting aside that 4 is an entirely sensible tab width... This seems to be the showstopper. Unless you now entirely own the code yourself alone, don't reformat it...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.