PyDev of the Week: Ken Youens-Clark

This week we welcome Ken Youens-Clark (@kycl4rk) as our PyDev of the Week! He is the author of Tiny Python Projects from Manning. He has done video lectures for each of his chapters on YouTube.

Ken Youens-Clark

Let’s spend some time getting to know Ken better!

Can you tell us a little about yourself (hobbies, education, etc):

I grew up playing the drums and initially was a music major in college for a couple of years. I changed my major in college several times, finally ending up with a BA in English literature and a minor in music. After college, I started playing the electric and upright basses in bands, and over the last few years, I’ve mostly enjoyed playing the piano, fiddle, drums, and sometimes the bodhran. I love cooking, especially baking for my family, and my wife and I love watching “The Great British Baking Show” and reading cookbooks for inspiration.

I never studied computer science and learned programming on the job. I had a TRS-80 as a kid, but I probably never wrote more than a hundred lines of BASIC on it. The first language I got paid to write was Visual Basic on Windows 3.1. I worked as a desktop Windows programmer in the late 90s before becoming enamored of this “internet” thing when I switched to working in Unix and Perl. That lead me into a web developer position in a genomics lab which turned into a career in bioinformatics.

I start my MS at the University of Arizona (UA) in 2015, 20 years after completing my undergraduate degree, and finished in 2019.

Why did you start using Python?

While working in the lab of Dr. Bonnie Hurwitz at UA, I was fortunate to help her teach beginning programming skills to biologists and engineers. Starting in 2015, we used Perl since that was our favorite language and it was so widely used in bioinformatics.

After a couple of years it was clear that Python would be a better choice. Python’s syntax is simple, it had eclipsed Perl in scientific computing, and there were more jobs waiting for trained Python programmers.

Around 2017, I proceeded to convert all my training materials to Python and switched to coding in Python full-time so as to become proficient. The change really benefited me in my machine learning adventures, and I’ve found it’s my go-to language for most of my day-to-day development from command-line programs to web backends.

What other programming languages do you know and which is your favorite?

My first languages were Visual Basic and Delphi which I’ve completely forgotten. I can still hack Perl, and I write bash fairly well and often. I use Elm, a purely functional language which is a subset of Haskell, for dynamic web front-ends, and I also really enjoy working in Rust which I would have to say is probably my favorite right now.

What projects are you working on now?

I’m currently writing a new book for O’Reilly called _Reproducibly Bioinformatics with Python_. I hope it will be in early release before the end of 2020, and it should be published in 2021. All the code and tests for that can be found at https://github.com/kyclark/biofx_python.

A few months ago I started a new position at The Critical Path Institute in Tucson, AZ, and I’m currently working on an internal mirror of the clinicaltrials.gov website. That project involves Python on the back-end, Elm on the front-end, and some interesting databases both relational (like Postgres) and non-relational (like MongoDB).

Which Python libraries are your favorite (core or 3rd party)?

For command-line programming, I rely heavily on “argparse” to handle argument processing. When writing code, I use “yapf” (Yet Another Python Formatter) to format code, “ylint” and “flake8” to check formatting and style, “mypy” to check type annotations, and “pytest” for testing.

I could not work without regular expressions, so I often use the “re” module. I connect to databases like SQLite, MySQL, PostgreSQL, and MongoDB regularly, so those modules are very important to me. I think the “FastAPI” module is indispensable for writing back-end APIs.

Stylistically, I really enjoy using “itertools” and “functools” to write Python more like purely functional languages.

How did you end up being an author for Manning?

After moving my teaching material from Perl to Python and teaching it a couple of years, I decided I had enough material to publish something novel especially as no one seems to try teaching test-driven development to beginners. Initially, I approached O’Reilly with a very jumbled idea for a bioinformatics book that mixed games and puzzles with biological examples.

I was told to separate those, and the non-bioinformatics material became Tiny Python Projects.

What are the top three things you’ve learned as an author?

I really enjoy classroom teaching, and I learned how much I left out of my writing because I would extemporize in class and use my hands and the chalkboard. I’ve learned to create lots of diagrams and not assume any knowledge.

I also learned to use my classroom time with students to live-code examples rather than lecture. I found this was much more engaging for the students. They learned practically how to write a program from scratch, adding just one or two lines of code, and then running and testing the program.

This lead to how I try to write each chapter of my books around a single program, using this as a vehicle to teach a few concepts like regular expressions and file handling.

I try to teach how to start each program from a template and modify that step-by-step to satisfy a given test suite. I think this leads to chapters that are focused and self-contained, leaving the reader with a sense of having written a real program at the end of each chapter. Lastly, I’ve learned a great deal about writing inclusively.

I think life as a middle-aged, cis-het, white male has left me with a lot of unconscious bias, and I’ve had editors call me out on language that would not be welcoming to some communities. Little jokes I thought might lighten the text might come off poorly. I even came to see simple words like “just” or “simply” as terribly elitist, like “just write the algorithm” or “the answer is to simply do X.”

Learning anything is challenging, so I try to avoid any language that makes programming seem easy or light-hearted.

Is there anything else you’d like to say?

I always enjoyed the camaraderie of the Perl community, and I’ve found Python to be equally welcoming and supportive. In Perl I relied heavily on CPAN and managed to contribute a few modules of my own, and I’ve found that Python’s pypi is an equally terrific resource.

I enjoy so much about Python, but I also recognize that the language will allow you to make serious errors so I really stress the need to use type annotations with “mypy” and lots and lots of tests. This has been a central focus to my classroom teaching and both my books.

Thanks for doing the interview, Ken!