
Episode 256: Solving Problems and Saving Time in Chemistry With Python
The Real Python Podcast
What motivates someone to learn how to code as a scientist? How do you harness the excitement of solving problems quickly and make the connection to the benefits of coding in your scientific work? This week on the show, we speak with Ben Lear and Christopher Johnson about their book “Coding For Chemists.”
Christopher is an associate professor of chemistry at Stony Brook University. Ben is a professor of chemistry at Penn State’s Eberly College of Science. They’re long-time friends who decided to collaborate on a book after discussing the challenges of teaching coding to chemistry students.
The book targets chemists and other researchers who want to streamline common workflows with Python. It covers core Python concepts, data visualization, and data analysis topics by sharing common problems encountered in chemical research and presenting a complete Python-based solution for each problem.
We discuss how they collaborated on the book and decided what libraries and tools to include. We cover how LLM tools have affected classroom teaching and require new techniques to reinforce learning. We also dig into what motivates students to learn how to code.
Course Spotlight: Defining Python Functions With Optional Arguments
In this video course, you’ll learn about Python optional arguments and how to define functions with default values. You’ll also learn how to create functions that accept any number of arguments using args
and kwargs
.
Topics:
- 00:00:00 – Introduction
- 00:02:06 – Ben’s background and starting with Python
- 00:04:34 – Chris’ background and starting with Python
- 00:07:16 – What has sped up Python for your use?
- 00:08:22 – How did idea for the book start?
- 00:11:30 – Shifting publisher and new release time frame
- 00:12:24 – Three potential audiences
- 00:13:20 – The ubiquitous need for programming skills in science
- 00:15:05 – Difficult workflows with chemistry equipment
- 00:16:06 – What is a chart recorder?
- 00:16:34 – Working with proprietary equipment and exporting data
- 00:23:37 – Explaining how programming will help chemists
- 00:27:31 – Finding the problems to solve
- 00:29:09 – The classic common chemistry workflow
- 00:30:48 – Teaching Python in a classroom and starting with functions
- 00:35:05 – Helping students cultivate inspiration
- 00:37:06 – LLM and AI use by students
- 00:41:19 – Video Course Spotlight
- 00:42:36 – Using Spyder IDE and Positron
- 00:45:29 – How does the book cover notebooks and managing packages?
- 00:48:08 – Using marimo for archiving and sharing projects
- 00:50:25 – What was difficult to put into the book?
- 00:54:04 – What were you eager to share in the book?
- 00:55:54 – Teaching students about file management
- 00:58:13 – Sharing tools to plot data
- 01:01:45 – Choosing not to teach pandas and using NumPy arrays instead
- 01:04:03 – How can people learn more about the book?
- 01:05:20 – What are you excited about in the world of Python?
- 01:07:58 – What do you want to learn next?
- 01:10:50 – How can people follow your work?
- 01:12:15 – Thanks and goodbye
Show Links:
- Coding For Chemists - Getting Started
- Ben Lear - Eberly College of Science
- Christopher Johnson - Department of Chemistry
- Chart recorder - Wikipedia
- pandas - Python Data Analysis Library
- NumPy
- Spyder - The Python IDE that scientists and data analysts deserve
- Positron
- marimo - A next-generation Python notebook
- Streamlit - A faster way to build and share data apps
- Plotly - Data Apps for Production
- Bokeh
- Vega-Altair: Declarative Visualization in Python
- codechembook - PyPI
- CodeChemBook: Companion library for Coding for Chemists Book - GitHub
- Data Meets Design
- The Lear Laboratory
- Statistical Inference - 2nd Edition - George Casella - Roger Berger
- Johnson Lab @SBU
- Christopher J. Johnson - Google Scholar
- Benjamin Lear - Google Scholar