HOWTO write a function on Nov. 18, 2017 at 11:10 a.m. in Théâtre Marie Gérin-Lajoie (MGL)

Outline:

Writing a function that the compiler will accept is much easier than writing a function that will get through code review on the first pass. I've written and reviewed lots of functions and the same advice comes up again and again.

  • Your function should have three parts: input, transform, and output. You should do them in order and not intermingle the three.
  • Keep the function readable by giving your reader context and keeping the amount of implied context low.
  • You can mostly ignore cargo cult practices like one-entry-one-exit and strict function length limits. We'll talk about why those cults exist and how to defend against them in a code review.

Speaker

Jack Diederich

Jack has been using Python for over 15 years and is a Python core committer for 10 of those years. His PyCon talks (Stop Writing Classes, Name Things Once) are popular on the YouTubes.