From 7ad589a03c6817b77388348d409f88bda2738602 Mon Sep 17 00:00:00 2001 From: Lee Trout Date: Sun, 25 Mar 2012 13:25:00 -0300 Subject: [PATCH 1/2] Updated value checking in style guide with more explicit example for None. --- docs/writing/style.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/writing/style.rst b/docs/writing/style.rst index e54e6be20..c35ad4945 100644 --- a/docs/writing/style.rst +++ b/docs/writing/style.rst @@ -142,7 +142,9 @@ Check if variable equals a constant ----------------------------------- You don't need to explicitly compare a value to True, or None, or 0 - you can -just add it to the if statement. +just add it to the if statement. See `Truth Value Testing +`_ for a +list of what is considered false. **Bad**: @@ -160,10 +162,14 @@ just add it to the if statement. # Just check the value if attr: - print 'True!' + print 'atter is truthy!' # or check for the opposite if not attr: + print 'attr is falsey!' + + # or, since None is considered false, explicity check for it + if attr is None: print 'attr is None!' Access a Dictionary Element From e9339cca50639ba56a255ab746e44ea73c07d0d8 Mon Sep 17 00:00:00 2001 From: Lee Trout Date: Sun, 25 Mar 2012 13:28:53 -0300 Subject: [PATCH 2/2] Corrected atter typo in style. --- docs/writing/style.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/writing/style.rst b/docs/writing/style.rst index c35ad4945..6ca8f221d 100644 --- a/docs/writing/style.rst +++ b/docs/writing/style.rst @@ -162,7 +162,7 @@ list of what is considered false. # Just check the value if attr: - print 'atter is truthy!' + print 'attr is truthy!' # or check for the opposite if not attr: