Each time you do not know if there will be a parameter NULL, you can use the following template:
SELECT * FROM table WHERE col = <parameter> OR (col IS NULL AND <parameter> IS NULL)
where <parameter>is your parameter.
, , dict. :
sql = 'SELECT * FROM table WHERE col = %(p)s OR (col IS NULL AND %(p)s IS NULL)'
possible_params = [{"p":1}, {"p":None}]
for x in possible_params:
print cur.mogrify(sql,(x,))