Let’s Code!

Grow your Python skills with detailed courses and articles that solve real-world problems.

Spotlight

Python Pattern Matching Examples: ETL and Dataclasses

Python’s new Structural Pattern Matching is useful in a wide range of roles, including ETL and data processing. Learn how to combine it with JSON, REST APIs and Python’s dataclasses.

Latest Articles

Python Pattern Matching Examples: ETL and Dataclasses

Python’s new Structural Pattern Matching is useful in a wide range of roles, including ETL and data processing. Learn how to combine it with JSON, REST APIs and Python’s dataclasses.

Mastering Structural Pattern Matching

In this course you’ll learn how to use Python 3.10’s new Structural Pattern Matching feature, and why Python would suddenly adopt a complex feature usually reserved for functional programming languages.

Watch out for mutable defaults in function arguments

You can set default values for function or method arguments, but think twice before you pick something that is mutable or can cause side-effects.

Inspired Tips

Inspirations for busy people

Inspired Python
def current_datetime(dt = datetime.datetime.now()):
    print(dt)

>>> current_datetime()
2021-10-09 16:09:43.009959
>>> current_datetime()
2021-10-09 16:09:43.009959

Python Anti-Patterns: Argument Side Effects


Be extra careful if you assign the result of a function call to a default argument. Python evaluates argument defaults on module load, so if your function is non-deterministic or has side-effects, you could run into trouble. As the example shows, the printed time is frozen; it was set once when the code was first evaluated.

Be Inspired Get Python tips sent to your inbox

We'll tell you about the latest courses and articles.

Absolutely no spam. We promise!