parts_cheatsheet

test_list_comp

[BODY for i in COMP_ITER if IFS[0] if IFS[1]]

test_dict_comp

{ KEY : VALUE for k, v in COMP_ITER if IFS[0] if IFS[1] }

test_generator_exp

(BODY for i in COMP_ITER if IFS[0] if IFS[1])

test_for_loop

for i in FOR_ITER:
    BODY
else:
    ORELSE

yes, you can put an else statement at the end!

test_if_else

if TEST:
    BODY
else:
    ORELSE

or, in the case of elif statements...

if TEST:
    BODY
ORELSE

test_lambda

lambda x: BODY

test_try_except

try:
    BODY
except BaseException:
    HANDLERS['BaseException']
except:
    HANDLERS['all']
else: 
    ORELSE
finally:
    FINALBODY

test_while

while TEST:
    BODY
else:
    ORELSE

test_with

with CONTEXT_TEST as context_var:
    BODY

test_function_definition

def f(a, b):
    BODY