473,888 Members | 1,302 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

coding conventions, PEP vs. practice


Dear python-list,

while looking for some coding conventions for python programs, i found the
PEP8 at http://www.python.org/peps/pep-0008.html. It defines the rules very
well and leaves no space for interpretations . I guess thats a good thing :-)
But when i started playing a bit with python and frameworks like Zope,
Webworks, etc., i noticed, that a lot frameworks are using a different
convention for methodnames.

These frameworks are using "mixedCase" but PEP8 suggests
"lower_case_wit h_underscores" except "in contexts where that's already the
prevailing style" which is not the case here IMHO.

So, are there any specific reasons for breaking the rules here? I think
consistent conventions are very important. Being a Java developer in the last
couple of years, i learned how practical it can be to have only one naming
style.

Best regards,

Roman

Jul 18 '05 #1
3 1597
Roman Roelofsen <r.*********@tu xed.de> wrote:
These frameworks are using "mixedCase" but PEP8 suggests
"lower_case_wit h_underscores" except "in contexts where that's already the
prevailing style" which is not the case here IMHO.

So, are there any specific reasons for breaking the rules here? I think
consistent conventions are very important. Being a Java developer in the last
couple of years, i learned how practical it can be to have only one naming
style.


My personal preference is camelCase over words_with_unde rscores, but
fundamentally, this is a bit of a religious issue. Pick a style, and go
with it.

If you're working on existing code, go with the prevailing style. If
you're working in a group, pick a common style and go with the group
decision. Of all the software engineering issues to worry about, this
is pretty low on the list.
Jul 18 '05 #2
Roman Roelofsen wrote:
Dear python-list,

while looking for some coding conventions for python programs, i found the
PEP8 at http://www.python.org/peps/pep-0008.html. It defines the rules very
well and leaves no space for interpretations . I guess thats a good thing :-)
But when i started playing a bit with python and frameworks like Zope,
Webworks, etc., i noticed, that a lot frameworks are using a different
convention for methodnames.


Note the first sentence of the PEP: "This document gives coding
conventions for the Python code comprising the standard library for the
main Python distribution."

It is not intended to be a style guide for all Python code although many
groups do adopt all or part of it for their own style guides.

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
Jul 18 '05 #3

"Robert Kern" <rk***@ucsd.edu > wrote in message
news:cr******** **@news1.ucsd.e du...
Note the first sentence of the PEP: "This document gives coding
conventions for the Python code comprising the standard library for the
main Python distribution."


Even that should say "from now on". Some library code was written before
PEP8. And Guido has so far discouraged purely stylistic patches to
functioning code (because of the risk on introducing bugs where none
exist).

TJR

Jul 18 '05 #4

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

Similar topics

3
4574
by: David Inada | last post by:
w3c talks about scripting and gives examples. But I could not find a coding standard for ASP/VBScript. I am trying to find any standards and tools to apply those standards to my companies ASP/VBScript codebase. I am thinking that HTML Tidy can at least go through and cleanup the HTML codebase?! David
13
4120
by: RainBow | last post by:
Hi everyone, (Very Sorry, if this is the wrong group in which I am posting this query). Code snippet: //C library typedef int (*PFunc)(int* aArg); void call_c_foo(PFunc aPtrtoFunc) {
144
7001
by: Natt Serrasalmus | last post by:
After years of operating without any coding standards whatsoever, the company that I recently started working for has decided that it might be a good idea to have some. I'm involved in this initiative. Typically I find that coding standards are written by some guy in the company who has a way of coding that he likes and then tries to force everybody else to write code the way he likes it, not for any rational reason, but simply for the...
7
2573
by: Ralph Lund | last post by:
Hi. I am starting a new project with C#. I am searching for "good" coding conventions. I know that there are some coding conventions from microsoft, (but they are very extensive and not clear). In the example programs of Microsoft they use different coding conventions: private members sometimes with underscore, sometimes without; when calling a method sometimes: method(param1, param2) or method ( param1, param2) (with or without...
48
1819
by: Robert Jacobson | last post by:
Hello all, If I have a class called "Foo," is there a preferred naming convention for iterating through each Foo instance in a collection of Foos? I've seen several different variations, even in the MSDN documentation: #1: For each Foo as Foo in Foos ...
4
2030
by: Josh Golden | last post by:
i lead a small development team (based on some of my posts that might cause some people to choke themselves, but have no fear, i am NOT the lead developer, the people on my team are great - i'm just the manager) for my company. although we attempt to use good practices for development, we have no real experience in documentation of a project _before_ it's coded. Are there any great books out there on how to document a project before we...
10
3009
by: Ren | last post by:
Hi All, I'm still rather new at vb.net and would like to know the proper way to access private varibables in a class. Do I access the variable directly or do I use the public property? public class MyClass private _variableName as integer public property VariableName as integer
23
2454
by: Thorsten Kampe | last post by:
Okay, I hear you saying 'not another naming conventions thread'. I've read through Google and the 'naming conventions' threads were rather *spelling conventions* threads. I'm not interested in camelCase versus camel_case or anything mentioned in 'PEP 8 -- Style Guide for Python Code'. What I'm looking for is hints or ideas how to name your variables and especially how to name functions, methods and classes.
12
1792
by: Christopher Key | last post by:
Hello, I've some code which I'd like to release in object form along with a suitable header. Before I do this however, I'd like to finalise the exact names for everything declared in the header, and want to make sure that I make the right choice, both with regards readability and following existing standards. I was wondering if there are any style guides or what peoples opinions are on the following: 1) Everything declared starts...
0
9802
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11186
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10780
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10439
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9597
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7148
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6015
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4248
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3252
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.