Also, while I'm using the dictionary method so it doesn't even matter, I think this pattern:
`variable = something.here
if condition:
    variable = something else goes here`

is really not great. It performs two assignments, for starters, which is almost guaranteed to be slower than an if/else, and I also think it's less clear that you're making a choice between the two things. So I really wouldn't change things to match that pattern, it doesn't seem to be beneficial.