Summary The venerable ‘if’ statement is a cornerstone of program flow and busines logic, but sometimes it can grow unwieldy and lead to unmaintainable software. One alternative that can result in cleaner and easier to understand code is a state machine. This week Glyph explains how Automat was created and how it has been used to upgrade portions of the Twisted project. Preface Hello and welcome to Podcast.__init__, the podcast about Python and the people who make it great. I would like to thank everyone who supports us on Patreon. Your contributions help to make the show sustainable. When you’re ready to launch your next project you’ll need somewhere to deploy it. Check out Linode at www.podastinit.com/linode?utm_source=rss&utm_medium=rss and get a $20 credit to try out their fast and reliable Linux virtual servers for running your awesome app. Visit the site to subscribe to the show, sign up for the newsletter, read the show notes, and get in touch. To help other people find the show please leave a review on iTunes, or Google Play Music, tell your friends and co-workers, and share it on social media. Your host as usual is Tobias Macey and today I’m interviewing Glyph about Automat, a library that provides self-service finite-state machines for the programmer on the go. Interview Introductions How did you get introduced to Python? What is a state machine and when might you want to use one? There are a number of libraries available on PyPI that facilitate the creation of state machines. Why did you feel the need to build a new option and how does it differ from what was already available? Why do you think developers fall into the trap of complicated conditional structures rather than reaching for a state machine? For someone who wants to integrate Automat into their project how would they go about that and what are some of the gotchas that they should keep in mind? What do the internals of Automat look like and how did you approach the overall design of the project? What are some of the more difficult aspects of designing and implementing state machines properly? What are some of the technical hurdles that you have been faced with in the process of building a library for implementing state machines? What do you have planned for the future of Automat? What are some of the most interesting use cases of Automat that you have seen? Keep In Touch Email @glyph on Twitter Glyph on GitHub Picks Tobias Commercial Electric color changing LED puck lights Glyph OmniFocus GTD Links Automat Glyph Interview About Software Ethics Finite State Automaton Yacc Bison Flex Parser Generator PyPI State Machine Pure Mealy Machine Moore Machine Mealy vs. Moore Machines Leaky Abstraction The Law of Leaky Abstraction Twisted Python Descriptor GraphViz Hypothesis PyCon Talk – TLS State Machine The intro and outro music is from Requiem for a Fish The Freak Fandango Orchestra / CC BY-SA