Rather than setting these to None, and then using if statements to set them, you could use the dict get() with None as the default. It would cut the above 6 lines to just 2.