The pynvl-lib will do it:
from pynvl import nvl
part_number = None
substr = "1234567"
fallback = "not in defn table"
print(nvl(part_number, nvl(substr, fallback))) # '1234567'