test for membership should be 'not in'
14def set(pin, state):
15 if pin not in pins:
16 abort(code=404, text="pin useless")
17 if not state in (1, 0):18 abort(code=400, text='invalid state '+str(state))
19
20 gpio.output(pin, state)
Description
Tests for membership should use the form x not in the_list
rather than not x in the_list
. The former example is simply more readable.
Bad practice
if not x in authors:
authors.append(x)
Recommended
if x not in authors:
authors.append(x)