Distilling PEP 8 for Teaching Introductory Programming

Diana Kirk, Andrew Luxton-Reilly, Ewan D. Tempero · 2025

Writing code that exhibits 'good style' is considered important in industry because such code is easier to understand and change and so reduces ongoing maintenance costs.It is therefore appropriate that computer science educators teach students how to write such code.However there are challenges in doing so.Professional style guides such as PEP 8 exist, but they are not designed for teaching as they contain content that is not suitable for introductory programming courses and often present advice without explaining why it should be adopted.This means that instructors who wish to base style instruction on an accepted standard must spend time extracting relevant information and adapting guidelines for teaching.We believe that a more systematic and rigorous approach to embedding style in our courses is necessary, and there is value in aligning what we do with industry practices to better prepare students.In this paper, we describe a study to create a Python primer based on PEP 8 for instructors of introductory programming courses.We used a Code Style Model (CSM) as a basis for explaining how the individual guidelines relate to broader principles of quality and clarifying why the guidelines should be adopted.Our contribution is a Python primer for code style based on PEP 8.

Read the paper · More papers on PaperTik