From 424ad34281beb67dcb5cd9294d638d564169d061 Mon Sep 17 00:00:00 2001 From: "apicard@google.com" Date: Tue, 18 Sep 2012 23:16:02 +0000 Subject: [PATCH] Updating python style guide --- pyguide.html | 298 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 202 insertions(+), 96 deletions(-) diff --git a/pyguide.html b/pyguide.html index af00822..30357f3 100644 --- a/pyguide.html +++ b/pyguide.html @@ -136,7 +136,7 @@

Google Python Style Guide

- Revision 2.29 + Revision 2.39

@@ -165,12 +165,12 @@ +pychecker Imports Packages Exceptions Global variables Nested/Local/Inner Classes and Functions List Comprehensions Default Iterators and Operators Generators Lambda Functions Conditional Expressions Default Argument Values Properties True/False evaluations Deprecated Language Features Lexical Scoping Function and Method Decorators Threading Power Features +Semicolons Line length Parentheses Indentation Blank Lines Whitespace Shebang Line Comments Classes Strings Files and Sockets TODO Comments Imports formatting Statements Access Control Naming Main @@ -223,7 +223,7 @@
Run pychecker over your code.
-
@@ -586,7 +594,7 @@ from sound.effects import echo link
- Use default iterators and operators for types that support them, + Use default iterators and operators for types that support them, like lists, dictionaries, and files.
+

Conditional Expressions

+ + link + +
+ Okay for one-liners. +
+
+
+

Default Argument Values

link @@ -726,7 +765,7 @@ from sound.effects import echo "faking" the overloading behavior.

-Cons: +Cons: Default arguments are evaluated once at module load time. This may cause problems if the argument is a mutable object such as a list or a dictionary. If the function modifies @@ -765,8 +804,8 @@ from sound.effects import echo link

- Use properties for accessing or setting data where you would - normally have used simple, lightweight accessor or setter methods. + Use properties for accessing or setting data where you would + normally have used simple, lightweight accessor or setter methods.
@@ -995,7 +1034,7 @@ from sound.effects import echo local variable, even if the use precedes the assignment. If a global declaration occurs, the name is treated as a global variable. - +

An example of the use of this feature is:

@@ -1018,7 +1057,7 @@ from sound.effects import echo

Cons: - Can lead to confusing bugs. Such as this example based on + Can lead to confusing bugs. Such as this example based on PEP-0227:

 i = 4
@@ -1034,7 +1073,7 @@ from sound.effects import echo
       

So foo([1, 2, 3]) will print 1 2 3 3, not 1 2 3 4. -

+

Decision: @@ -1132,7 +1171,7 @@ from sound.effects import echo

- Use the Queue module's Queue data type as the preferred + Use the Queue module's Queue data type as the preferred way to communicate data between threads. Otherwise, use the threading module and its locking primitives. Learn about the proper use @@ -1171,7 +1210,7 @@ from sound.effects import echo difficult than code that is longer but is straightforward.

-Decision: +Decision: Avoid these features in your code.

@@ -1202,8 +1241,8 @@ from sound.effects import echo