Interactive command line tools can be useful – but asking for input is hard.
How do you ask your user a question? Get them to make a choice? Select a path? You have input() … and what else?
In this talk, we’ll look at some of the tips and tricks for writing interactive scripts and tools in Python.
Creating a good interactive command line tool is hard. When you ask the user for input, you can get a raw string from input() – but then you have to parse that, validate it, give friendly error messages if something goes wrong – and making that work nicely is time you’re not spending on the core functionality of your tool.
The Python ecosystem has libraries that can help you do this, including click, inquirer, and tqdm – but they’re not widely known.
In this talk, I’ll show you a toolbox of libraries that make it easier to write great interactive command line tools.
Alex Chan is a software developer at Wellcome Collection, a museum and library of digital preservation software. Alex Chan also helps to organise PyCon UK and writes about running inclusive events, and sometimes dabbles in bits of open-source Python. Away from computers, Alex Chan finds joy in sparkles, sewing, and swing dancing.