Earlier quoted context omitted.
Depending on your perception, x.get is either error recovery (good) or a silent failure (bad). One is not necessarily better than the other; it depends on what you want. In my experience, x[] is usually the better choice because failing fast makes debugging easier. I hope no one is recommending x.get as a general practice, because that is pretty naive.
You're right, but actually... If you're a very junior sw engineer reading this, who hasn't done a lot of python, use x.get(). Almost always, so for you, always. This doesn't apply if you're a scientist or mostly writing small scripts, but if you are doing SWE, always use x.get(). Once you've understood python you can use x[] in limited cases. Never in your unit or functional tests. I code using x[], but later on I re…
Non-python dev here.