Professional Python and Best Practices

Helping your team improve their skills in delivering high-quality code.

Does your team struggle to deliver high quality code? Are you unsure how to organize your project or which tools to use? In this course we teach best practices in a project-based setting.
3-5 days
ansible python
Anyone with at least one year of experience programming Python
Improve general Python skills, with a focus on writing robust, maintainable code.
The course will be very practical and hands-on. Each morning we will present some theory with exercises, and the afternoon will be spent working on an overarching project, in groups of 3 or 4 people.
Need this for your dev team?

Outline

Below is an example of how this course might be delivered. This course will always be customized to meet your teams needs. If possible we will prepare a project - based on the actual development environment in your company - for the participants to apply their learnings.

Labs/Exercises

There are exercises available for all topics covered.

Day 1: Core Python recap

We start off by refreshing core Python concepts to make sure everyone is on the same page. The amount time spent on core Python skills is adjusted according to the experience level of the participants.

  • Course Introduction
  • Group Introductions
  • Variables
  • Basic data types (int, str, float, bool)
  • Input, Output, Type Conversions
  • If statements
  • While loops
  • Functions
  • Lists
  • Dicts
  • Tuples
  • Sets
  • For Loops
  • Exceptions
  • Git Basics
  • Project start

Day 2: Best Practices

This day focuses on general best practices and tooling for code styling and type checking.

  • Code styling (pep8)
  • Documentation (pep257)
  • Type hinting
  • Overview of type hints
  • Semantics of type hints
  • When to add type hints
  • Linting (flake8, pylint, etc.)
  • Auto-formatting with black
  • Continuous integration
  • Code Reviews
  • Applying learnings in a project

Day 3: Correctness

Covering techniques to make sure the functionality is correct in a formalized way.

  • Debugging tips and tricks
  • Using breakpoints
  • Understanding stack traces
  • Watching variables
  • Unit testing
  • Mocking
  • Fixtures
  • Exception handling
  • Best practices, i.e. where and how to handle exceptions
  • (Re-)raising exceptions and “raise from”
  • Custom exceptions
  • Applying learnings in a project

Day 4: Object Orientation and Architecture

  • Object oriented programming
  • Magic methods
  • Inheritance
  • Dataclasses
  • The object spectrum: tuple-namedtuple-dict-dataclass-class
  • Choosing OOP vs functional-style programming
  • Organizing code in modules/classes/functions
  • Interface design and encapsulation
  • Abstract base classes and protocols
  • Loose coupling, high cohesion
  • Single responsibility principle
  • Law of demeter
  • Applying learnings in a project

Day 5: Intermediate Python

This day is meant for deepening the Python knowledge of the team.

  • Args en kwargs and unpacking
  • Function arguments in-depth
  • Comprehensions
  • Lambda, map, filter
  • Generators and the iteration protocol
  • Decorators
  • Context managers
  • Custom attribute access (getattr and friends)
  • Applying learnings in a project
  • Teams review each others code
Adapt this course to fit your needs