473,414 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 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 1781
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.