Added a note on compound statements after remarks from David Goodger.

Make the code samples agree with this recommendation. ;)
This commit is contained in:
Barry Warsaw 2002-10-17 15:32:18 +00:00
parent 5f41fd9b90
commit 8e4c8019b1
1 changed files with 13 additions and 2 deletions

View File

@ -238,6 +238,17 @@ Whitespace in Expressions and Statements
def complex(real, imag=0.0): def complex(real, imag=0.0):
return magic(r=real, i=imag) return magic(r=real, i=imag)
- Compound statements (multiple statements on the same line) are
generally discouraged.
No: if foo == 'blah': do_blah_thing()
Yes: if foo == 'blah':
do_blah_thing()
No: do_one(); do_two(); do_three()
Yes: do_one()
do_two()
do_three()
Comments Comments
@ -580,8 +591,8 @@ Programming Recommendations
- Don't compare boolean values to True or False using == (bool - Don't compare boolean values to True or False using == (bool
types are new in Python 2.3): types are new in Python 2.3):
No: if greeting == True: print "Hello world" No: if greeting == True:
Yes: if greeting: print "Hello world" Yes: if greeting:
References References