Pythonic way of checking for dict keys When checking a python dict for a key, which is the better way here:
(I can't figure how to use dict.get() to make this cleaner)

if 'y' in self.axes:
    ax = self.axes['y'].ax
    coord1[ax] = x0
    coord2[ax] = (y1) - height[ax]
    coord3[ax] = x0 + width[ax]
    coord4[ax] = y1


or:

try:
    ax = self.axes['y'].ax
except KeyError:
    pass
else:
        coord1[ax] = x0
        coord2[ax] = (y1) - height[ax]
        coord3[ax] = x0 + width[ax]
        coord4[ax] = y1


The latter way is closer to EAFP but former seems clearer, especially for new code contributors who are scientists first &amp; coders second.
Both ways are valid and have their own advantages. Checking upfront using an if statement involve a bit of overheard for each usage, using EAFP involve greater overheads but only for the "wrong" case.

So if you mostly have cases where 'y' is in self.axes then EAFP is better, otherwise LBYL is fine.

But if you only are calling this pattern a handful of times, then either will do; or no, use the third approach contextlib.suppress because this except: pass is ugly:

from contextlib import suppress


with suppress(KeyError):
    ax = self.axes['y'].ax
    coord1[ax] = x0
    coord2[ax] = (y1) - height[ax]
    coord3[ax] = x0 + width[ax]
    coord4[ax] = y1