Yes: import os
import sys
No: import sys, os
Yes: spam(ham[1], {eggs: 2})
No: spam( ham[ 1 ], { eggs: 2 } )
Yes: foo = (0,)
No: bar = (0, )
Yes: if x == 4: print x, y; x, y = y, x
No: if x == 4 : print x , y ; x , y = y , x
Yes: if greeting:
No: if greeting == True:
Worse: if greeting is True:
Yes: if foo.startswith('bar'):
No: if foo[:3] == 'bar':
Yes:
def foo(x):
if x >= 0:
return math.sqrt(x)
else:
return None
No:
def foo(x):
if x >= 0:
return math.sqrt(x)
joined_lower for functions, methods, attributes, variables
joined_lower or ALL_CAPS for constants
StudlyCaps for classes
camelCase only to conform to pre-existing conventions