Juha-Matti Santala
Community Builder. Dreamer. Adventurer.

Blog posts in category “Python”

Snakes, snakes everywhere.

  • Aug 31st, 2024
    Blaugust 2024 retrospective

    Another Blaugust finished with 31 posts in 31 days. I got to share my love for Python and its standard library over a series of posts that hopefully inspired readers to learn something new.

  • Aug 30th, 2024
    Book recommendation: Fluent Python (2nd Edition)

    Fluent Python is one of the best - if not the best - Python books and will help you become better at writing pythonic code.

  • Aug 29th, 2024
    What’s coming to Python in 3.13 and 3.14

    With new Python versions in the horizon, what goodies can we expect to see?

  • Aug 28th, 2024
    Couple of great Python podcasts

    Python community has so many great podcasts to learn more from. Here are 4 picks of the ones I’ve been mostly listening lately.

  • Aug 27th, 2024
    Quick prototyping with sqlite3

    Python’s sqlite3 bindings makes it a great tool for quick prototyping while you’re working out what it is exactly that you’re building and what kind of database schema makes sense.

  • Aug 26th, 2024
    Parse command line arguments with argparse

    In 2021 I wrote a blog post documenting argparse in a way that made more sense to me. This year for Blaugust and Batteries included, I want to resurface that for those who are new to argparse.

  • Aug 25th, 2024
    Pretty print and validate JSON on command line with json.tool

    Python has a variety of command line interfaces that can be run without writing any code or starting a REPL. Json module has one that I use quite regularly.

  • Aug 24th, 2024
    Test your codebase with unittest

    Few weeks ago I wrote about doctest and today, I’m looking into another way to write tests that is built in to Python: unittest.

  • Aug 23rd, 2024
    Branch out with pattern matching

    Since Python 3.10, Python has had support for pattern matching which is made it my all-time most anticipated release when it came out. It makes branching while capturing data to variables a breeze once you get used to it.

  • Aug 22nd, 2024
    Serve local HTML and CSS files with http.server

    python -m http.server provides a handy way to spin up a local server for your files.

  • Aug 21st, 2024
    Bring your custom toolkit to REPL sessions

    You can bring in your favourite tooling and most used imports to every REPL session with environment variable PYTHONSTARTUP.

  • Aug 20th, 2024
    Keep track of happenings with logging

    Python provides good basic functionality for logging in its standard library.

  • Aug 19th, 2024
    Memoize with functools.cache

    Do you have computationally expensive functions that are called often? Memoizing is a strategy that caches results in memory so the full computation can be skipped in future calls.

  • Aug 18th, 2024
    map and filter with list comprehensions

    Python has map and filter functions but we like to use list comprehensions instead because they flow off the tongue so smoothly.

  • Aug 17th, 2024
    Combine iterables with zip

    Combine or iterate over multiple iterators at once by zipping them together.

  • Aug 16th, 2024
    Random number chosen by fair dice roll

    Python’s random module offers tools to generate pseudo-random numbers.

  • Aug 15th, 2024
    Write more pythonic code with context managers

    Context managers enable you to create “template” code with initialisation and clean up to make the code that uses them easier to read and understand

  • Aug 14th, 2024
    Combinatoric iterators from itertools

    itertools module offers four combinatoric iterators that generate different combined outputs from one or more iterable.

  • Aug 11th, 2024
    Data classes in Python with dataclasses

    Python has a couple of methods to implement data class pattern. Last week, I looked into namedtuples and today, I’m writing about a newer option: dataclasses.

  • Aug 10th, 2024
    Rotating turn order with deque

    deque is a double-ended queue that I’ve used to implement rotating turn order for a (very simplified) game engine.

  • Aug 9th, 2024
    Debug with pdb and breakpoint

    Python’s standard library comes with good tooling to debug your code – and a lot of community-made tooling that can be configured to take your debugging productivity to a whole new level.

  • Aug 8th, 2024
    Document intended usage through tests with doctest

    There’s a lot to like about Python’s doctest module. It enables you to write tests as examples in your documentation, fulfilling two important duties of tests.

  • Aug 7th, 2024
    Improved print readability with pprint

    Pretty print module provides more readable prints for complex data structures

  • Aug 6th, 2024
    help() me Obi-Wan Kenobi, you’re my only hope

    Python’s built-in help system is your companion when developing or debugging Python code.

  • Aug 5th, 2024
    Count ‘em

    Python’s Counter provides a way to count items in iterables or mappings and get them in a dictionary-like object with a small handful of handy methods.

  • Aug 4th, 2024
    Improve your code with namedtuples

    We continue our journey in Python standard library by taking a look one of my absolute favorites: namedtuple. It’s like a regular tuple but adds documentation, making your code cleaner and easier to read.

  • Aug 3rd, 2024
    Reading and writing CSV with Python

    Python has great tools for reading and writing data in CSV format.

  • Aug 2nd, 2024
    Parsing nginx server logs with regular expressions

    Regular expressions are fun. In this series of Batteries included, I write about Python’s standard library with practical examples.

  • Aug 1st, 2024
    Blaugust 2024: Batteries included

    August’s blogging festival Blaugust is here again and this year, I’m writing about the goodies in Python’s standard library.

  • May 12th, 2024
    Two small hockey web projects

    Spring is the best time of hockey fans: NHL playoffs and IIHF World Championships fill days and nights with hockey. For me, that means running fun community projects and building software for them.

  • Apr 1st, 2024
    Documentation pages from dotfiles with config-renderer

    Making dotfiles readable isn’t always easy. To tackle that challenge, I created config-renderer, a Python CLI tool that documents dotfiles as HTML pages with a bit of custom markup.

  • Jan 25th, 2024
    Python Bytes featured Syntax Error

    In the episode 368 of Python Bytes, Brian talks about my January newsletter issue of Syntax Error.

  • Jan 17th, 2024
    I wish Python had Integer.times

    Ruby has a wonderful method times in Integer class. For readability reasons, I wish Python had something similar as well.

  • Jan 13th, 2024
    Debugging Python

    How to figure out what happens when the computer says no? This article is the written form of my Debugging Python talk I’ve given a couple of times lately. It explores both technical and non-technical approaches to being a code detective.

  • Jan 3rd, 2024
    Advent of Code 2023 retrospective

    Last month I participated in Advent of Code again, helping the elves to save Christmas. By 25th, I reached 36 stars and learned a bunch of new things.

  • Dec 6th, 2023
    We’re building community for Python developers

    archipylago is a new community for developers interested in Python in Turku region

  • Aug 27th, 2023
    Compressing overlapping strings in Python

    I developed a solution to a overlapping string puzzle with Python using Test-Driven Development and in this blog post, I share my thinking and development process.

  • Nov 30th, 2022
    Python prep for Advent of Code 2022

    Advent of Code is right around the corner and I decided to gather my favorite Python tips and standard library tools from my previous years' puzzle-solving.

  • Jul 28th, 2022
    I wrote my first Dropzone 4 action

    I recently got into two new apps: open source video player called Iina and a macos menu bar tool Dropzone. Then I wrote a Python script to connect the two. Beautiful.

  • Jul 13th, 2022
    Unit test your Python code in Jupyter Notebooks

    I used learned Jupyter Notebook for last year's Advent of Code but didn't have time in December to figure out how to test my code in that environment. Getting ready for the winter season, I took some time this summer holiday to explore the options and I'm sharing three ways in this blog post.

  • Jun 8th, 2022
    print is your best debugging tool

    One tool to rule them all, one tool to find them (bugs). One tool to bring them all, and in the editor fix them.

  • Apr 14th, 2022
    My trip to Django Day Copenhagen 2022 and Stockholm

    Django Day Copenhagen 2022 was a wonderful event full of great talks and amazing people. Here's my recap of my trip to the event.

  • Dec 31st, 2021
    45 stars, Christmas was almost saved - Advent of Code retrospective

    Advent of Code for this year is done and for the first time in my life, I got almost to completion with 45 stars and saving the Christmas! Here's my Advent of Code 2021 retrospective of the things I learned and experienced during this month.

  • Dec 15th, 2021
    Tips for Advent of Code

    Solving Advent of Code puzzles is a fun way to spend December. Over the years I've participated, I've picked up a habit or two that makes debugging broken solutions easier.

  • Dec 8th, 2021
    Advent of Code 2021

    This year I'm once again solving Advent of Code puzzles to help the elves save the Christmas. This year, my trusty tools are Python and Jupyter Notebook and I'm focusing on writing my thoughts and insights for other humans within my notebooks.

  • Oct 6th, 2021
    Python 3.10 is out and I'm excited

    A long-awaited release of Python 3.10 is finally here. Its two major new things are the introduction of pattern matching and the improved error messages.

  • Sep 29th, 2021
    How would you compare two version numbers?

    Comparing two software version numbers may sound simple and straightforward. I ran into a discussion about it in Twitter and explored further.

  • May 19th, 2021
    Scheduling operations in Python

    Do you have a need to run a Python function on regular intervals, like every hour or on 12.00 each Monday? Python package schedule makes it easy and its API is beautiful and easy to understand.

  • Mar 17th, 2021
    How to parse command line arguments in Python

    Python is a great language for writing command line applications. Its built-in tool for parsing arguments is powerful and I gathered together some of the most used cases.

  • Feb 17th, 2021
    Pattern matching is coming to Python

    Pattern matching is coming to Python this year and I'm so excited for it! I'll walk you through what is pattern matching and how it's gonna work in Python.

  • Oct 28th, 2020
    How to ask help for technical problems?

    Asking for help in technical problems can end up in a lot of back and forth before even getting to the bottom of the issue. Here are some tips how to effectively ask for help.

  • May 27th, 2020
    How to scrape a website with Python & BeautifulSoup

    Learn how to scrape data from websites using Python and BeautifulSoup so that you can use it in your scripts and applications.

  • Apr 30th, 2020
    True, True, True == (True, True, True) in Python

    A friend shared this interesting piece of Python code in our Telegram chat today and I wanted to walk you through it.

  • Apr 1st, 2020
    Testing lifehack: testlab repositories

    Sometimes it's hard to set up tests in a legacy project so I built testlab repositories so I can do TDD when I develop new functionality.