Added a note on compound statements after remarks from David Goodger.
Make the code samples agree with this recommendation. ;)
This commit is contained in:
parent
5f41fd9b90
commit
8e4c8019b1
15
pep-0008.txt
15
pep-0008.txt
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue