No Surprises, Please!

Experience Level: all

Users generally don’t like being forced into doing unnecessary work. And the least they like is being forced into thinking. Your way.


  • Timeslot: Sunday, 6th April 2025, 15:00-16:00, Room C
  • Tags: other

The principle of the least astonishment describes how the code behavior and structure meet the users’ expectations. We’ll consider all three levels: code output, API&docs, and the source code itself:

  1. Probably every user will see the runtime output of your code. Make it readable. Include as little as possible and as much as needed. Give the user exactly what they require and guide them through the rest. Make error messages actually useful. Don’t reinvent keyboard shortcuts.
  2. Some users will use your API. Define it clearly and consistently. Give the users some examples. Don’t force them to read the whole documentation, but still present it in a useful way.
  3. And there will be some adventurers who will even dive into your source code to understand how it works, Structure well, write some comments, follow a style.

For all three levels we’ll look at some examples and discuss how to stick to good habits of not surprising the user.


Miroslav Šedivý

Using Python to make the sun shine and the wind blow. Greedy polyglot, sustainable urbanist, unicode collector, Python Software Foundation Fellow.

miroslav-sedivy