From db989ec08fe5518413836641ca0ab8385bb2e2d9 Mon Sep 17 00:00:00 2001 From: mmentovai Date: Tue, 23 Nov 2010 18:02:36 +0000 Subject: [PATCH] Update C++ style guide to 3.180: - Remove comment about naming macros like enums. - Move a bad code snippet from a CODE_SNIPPET to a BAD_CODE_SNIPPET element. Update Python style guide to 2.18: - Clarify the syntax for import statements. Update styleguide.xsl to 1.31: - Substitute underscore for apostrophe in anchor names. --- cppguide.xml | 10 +++++---- pyguide.html | 59 ++++++++++++++++++++++++-------------------------- styleguide.xsl | 4 +++- 3 files changed, 37 insertions(+), 36 deletions(-) diff --git a/cppguide.xml b/cppguide.xml index 507a569..c335fc7 100644 --- a/cppguide.xml +++ b/cppguide.xml @@ -4,7 +4,7 @@

-Revision 3.178 +Revision 3.180

@@ -739,9 +739,11 @@ Tashana Landray particular, initialization should be used instead of declaration and assignment, e.g.

- + int i; i = f(); // Bad -- initialization separate from declaration. + + int j = g(); // Good -- declaration has initialization.

@@ -3018,7 +3020,7 @@ Tashana Landray Please see the description of macros; in general macros should not be used. However, if they are absolutely needed, then they should be - named like enum value names with all capitals and underscores. + named with all capitals and underscores.

#define ROUND(x) ... @@ -4527,7 +4529,7 @@ Tashana Landray

-Revision 3.178 +Revision 3.180

diff --git a/pyguide.html b/pyguide.html index 23939e1..b2db3f7 100644 --- a/pyguide.html +++ b/pyguide.html @@ -100,7 +100,7 @@

Google Python Style Guide

- Revision 2.15 + Revision 2.18

@@ -262,35 +262,38 @@

Pros: - Simplest and most commonly used way of sharing things. + The namespace management convention is simple. The source of each + identifier is indicated in a consistent way; x.Obj says + that object Obj is defined in module x.

-Cons: from foo import * or - from foo import Bar is - very nasty and can lead to serious maintenance issues because - it makes it hard to find module dependencies. +Cons: Module names can still collide. Some module names are + inconveniently long.

Decision: - Use import x for importing packages and modules. - Use from x import y only when x is a - package and y is a module. This allows the - importer to refer to the module without specifying the full - package prefix. For example the module - sound.effects.echo may be imported as follows: + Use import x for importing packages and modules. +
+ Use from x import y where x is + the package prefix and y is the module name with no + prefix. +
+ Use from x import y as z if two modules named + z are to be imported or if y is an + inconveniently long name.

+ For example the module + sound.effects.echo may be imported as follows:
 from sound.effects import echo
 ...
-echo.echofilter(input, output, delay=0.7, atten=4)
+echo.EchoFilter(input, output, delay=0.7, atten=4)
 
 

- Even if the module is in the same package, do not directly import - the module without the full package name. This might cause the - package to be imported twice (with unintended side effects) when the - "main" module that is used to start an application lives inside a - package (and uses modules from that same package). + Do not use relative names in imports. Even if the module is in the + same package, use the full package name. This helps prevent + unintentionally importing a package twice.

@@ -300,8 +303,7 @@ link
- Import and refer to each module using the full pathname location of - that module. + Import each module using the full pathname location of the module.
@@ -1389,12 +1389,9 @@ from sound.effects import echo Always use the most specific version you can use, e.g., /usr/bin/python2.4, not /usr/bin/python2. This makes it easier to find - dependencies when - - upgrading to a different Python version + dependencies when upgrading to a different Python version and also avoids confusion and breakage during use. E.g., Does - /usr/bin/python2 mean Python 2.0.1 or Python - 2.3.0? + /usr/bin/python2 mean Python 2.0.1 or Python 2.3.0?

@@ -2028,7 +2025,7 @@ Don't do this.

-Revision 2.15 +Revision 2.18

diff --git a/styleguide.xsl b/styleguide.xsl index e82e8f1..38345d5 100644 --- a/styleguide.xsl +++ b/styleguide.xsl @@ -449,7 +449,9 @@ xmlns:fn="http://www.w3.org/2005/xpath-functions"> Substitutes underscore for characters unsuitable for URLs --> - + + +