Hello friend! This is a newsletter for builders.
What do you like to build?
I hope the ideas in this week’s newsletter can help you get it done.
In this weeks newsletter
🤔 Nervous energy
💻 Blog post: Python’s “try except else finally” explained
📜 Quote of the week
Nervous energy
You know that feeling. Before a presentation or big meeting.
When I get nervous I sweat a lot. I remember defending my M.Sc. thesis and completely sweating through both the undershirt and button up I was wearing, a force stronger than any anti-perspirant could withstand.
This is a side effect - a “necessary evil” if you will, that evolution has bestowed upon me.
See, in order to understand many things in life I turn to evolutionary biology. I ask questions like “in the ancestral environment, why would this behaviour be beneficial?”
Nervous energy exists to focus our attention on the task at hand. All else ceases to exist - hunger, thirst, tomorrow’s schedule, etc..
So next time you feel that nervous energy take a moment to appreciate why you feel that way and embrace the focus.
Blog post: Python’s “try except else finally” explained
I was browsing through a feature discussion on Github for the puckel docker-airflow image (issue #323 to be exact) and ran into this piece of code:
session = Session()
try:
exists_conn = session.query(
Connection.conn_id == conn.conn_id).one()
except exc.NoResultFound:
logging.info(
'connection not exists, will create it.')
else:
logging.info(
'connection exists, will delete it before create.')
session.delete(exists_conn)
finally:
session.add(conn)
session.commit()
session.close()
The purpose of this code is to replace an existing connection exists_conn
with a new one conn.
I’ve probably seen the else/finally used in the exception control flow before have never used it. Thus I was unsure exactly what was going on here.
A few stack overflow posts later and I was good to go. And in fact the code above is a great example to learn about it.
Let’s walk through it:
Start session.
(try) Assume connection has already been added to the database and retrieve it.
(except) If it doesn’t exist then let the user know.
(else) If the try statement succeeds then delete the connection.
(finally) Add the new connection instead.
End session.
If you want to read more and see another example of this control flow then check out my recent blog post on the topic at the link below:
https://medium.com/@galea/pythons-try-except-else-finally-explained-f04d47d57125
Quote of the week
“Striving to better, oft we mar what's well.”
-Shakespeare
There are so many angles to look at this from. What does it bring to mind for you?
In 2019 I started doing push ups - a lot of push ups. A few times a week I would be grinding out 100-200 reps.
Lots of work.
But with the wrong technique.
See, my scapula would splay out when I declined, causing strange muscle growth and contributing to bad posture, or so-called “scapular winging”.
With the proper posture (tucking my scapula to be flat with my back) I initially got in far fewer reps.
Now though I’m nearly back where I was in terms of reps and much further along in terms of healthy muscle growth.
-Alex
Subscribe the Datapipe weekly newsletter ⬇️