Basic coding style

spir denis.spir at gmail.com
Tue Nov 23 01:35:05 PST 2010


On Mon, 22 Nov 2010 13:50:44 -0700
Rainer Deyke <rainerd at eldwood.com> wrote:

> On 11/22/2010 13:25, spir wrote:
> > On Mon, 22 Nov 2010 11:24:20 -0700 Rainer Deyke <rainerd at eldwood.com>
> > wrote:
> > 
> >> On 11/22/2010 11:03, bearophile wrote:
> >>> If you write Python or C# code that other people are supposed to
> >>> use, then people will surely tell you that your coding style is
> >>> bad, if you don't follow their basic coding styles.
> >> 
> >> Python is a bad example to mention, methinks.  Even C++ has a more 
> >> consistent style.
> > 
> > ???
> > 
> > [What is such a wild judgement supposed to mean, Rainer? Python
> > certainly has one of the most sensible and consistent coding styles
> > in practice: http://www.python.org/dev/peps/pep-0008/. I do _not_
> > agree with half of it ;-) but it is consistent and sensible (and I
> > used it for all published code.)]
> 
> I'm talking about naming conventions, which I think is the most
> important part of a coding style.  The indentation level of a third
> party library doesn't affect my own code, so I don't care about it.  I
> Do care about naming conventions, because the naming convention used in
> third party libraries affects my own code.
> 
> The C++ standard library has a fairly consistent naming convention.  All
> words are lower case, usually separated by underscores, sometimes
> prefixed or postfixed with individual letters carrying additional meaning.
> 
> In Python, the general rule is that classes use CaptializedWords,
> constants use UPPER_CASE (with underscores), and everything else uses
> lowercase (usually without underscores).  However, these rules are
> broken all the time by Python's own standard library.  For example:
>   - Almost all built-in classes use lowercase.  In some cases this is
> for historical reasons because the name was originally used for a
> function.  However, even new built-in classes tend to use lowercase.
>   - Built-in constants 'None', 'True', 'False'.
>   - Some functions (e.g. 'raw_input') use underscores while most don't.
>  This is allowed by the style guide, but it's still an inconsistency.

All right, I understand better. Seems you're actually talking of python builtin names breaking its own standard, not of the standard itself.
The same applies to D (see my post) on the topic. I also find this _bad_, in any language. 

Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



More information about the Digitalmars-d mailing list