death.andgravity.com Open in urlscan Pro
2606:50c0:8000::153  Public Scan

Submitted URL: http://andgravity.com/
Effective URL: https://death.andgravity.com/
Submission: On May 24 via api from GB — Scanned from CA

Form analysis 1 forms found in the DOM

Name: mc-embedded-subscribe-formPOST https://gmail.us7.list-manage.com/subscribe/post?u=9909b0e978d8d8d941bd3c8dc&id=c61d63d661&SIGNUP=index

<form action="https://gmail.us7.list-manage.com/subscribe/post?u=9909b0e978d8d8d941bd3c8dc&amp;id=c61d63d661&amp;SIGNUP=index" method="post" id="embedded-subscribe-form" name="mc-embedded-subscribe-form" target="_blank" novalidate=""
  class="panel subscribe-form">
  <div class="panel-header text-large"> Want to know when new articles come out? </div>
  <div class="panel-body">
    <p>Drop your email in the box below and I'll send new stuff straight to your inbox!</p>
    <div class="form-group col-6 col-xs-12 col-md-9">
      <input type="text" name="FNAME" id="mce-FNAME" class="form-input input-lg" placeholder="Your first name">
    </div>
    <div class="form-group col-6 col-xs-12 col-md-9">
      <input type="email" name="EMAIL" id="mce-EMAIL" class="form-input input-lg" placeholder="Your email address">
    </div>
    <!-- bot prevention-->
    <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_9909b0e978d8d8d941bd3c8dc_c61d63d661" tabindex="-1" value=""></div>
  </div>
  <div class="panel-footer">
    <div class="form-group">
      <input type="submit" name="subscribe" id="mc-embedded-subscribe" class="btn btn-primary btn-lg" value="Subscribe">
    </div>
  </div>
</form>

Text Content

 *  


DEATH AND GRAVITY



Hi, I'm Adrian. Among other things, I write about Python on the internet.

If you're new here, people seem to like these articles:

 * Learn by reading code: Python standard library design decisions explained
   (for advanced beginners)
 * Struggling to structure code in larger programs? Great resources a beginner
   might not find so easily
 * When to use classes in Python? When your functions take the same arguments
 * Write an SQL query builder in 150 lines of Python!

Want to know when new articles come out?

Drop your email in the box below and I'll send new stuff straight to your inbox!






Here's a list of all the articles:

 * The unreasonable effectiveness of f‍-‍strings and re.VERBOSE  six minute read
   
   ... in which we look at one or two ways to make life easier when working with
   Python regular expressions.

 * yaml: could not determine a constructor for the tag  four minute read
   
   ... in which you'll find out what "could not determine a constructor for the
   tag" PyYAML errors mean, why do they happen, and what you can do about it.

 * Dealing with YAML with arbitrary tags in Python  10 minute read
   
   ... in which we use PyYAML to safely read and write YAML with any tags, in a
   way that's as straightforward as interacting with built-in types.

 * Write an SQL query builder in 150 lines of Python!  20 minute read
   
   This is the fourth article in a series about writing my own SQL query
   builder. Today, we'll rewrite it from scratch, explore API design, learn when
   to be lazy, and look at worse and better ways of doing things – all in 150
   lines of Python!

 * namedtuple in a post-dataclasses world  six minute read
   
   namedtuple has been around since forever, and over time, its convenience saw
   it used far outside its originally intended purpose. With dataclasses now
   covering part of those use cases, what should one use named tuples for? In
   this article, I address this question, and give a few examples from real
   code.

 * Why I wrote my own SQL query builder (in Python)  10 minute read
   
   This is the third article in a series about writing an SQL query builder in
   150 lines of Python. Here, I talk about why I decided to write my own, the
   alternatives I considered, why I didn't use an existing library, and how I
   knew it wouldn't become a maintenance burden.

 * When your functions take the same arguments, consider using a class:
   counter-examples  six minute read
   
   In this article, we look at a few real-world examples where functions taking
   the same arguments don't necessarily make a class, as counter-examples to a
   heuristic for using classes in Python.

 * Python sentinel objects, type hints, and PEP 661  seven minute read
   
   PEP 661 proposes adding a utility for defining sentinel values in the Python
   standard library. In this article, you'll get a PEP 661 summary, learn what
   sentinel objects are (with real-world examples), how to use them with type
   hints, and a bit about why PEPs exist in the first place.

 * When to use classes in Python? When your functions take the same arguments 
   five minute read
   
   In this article, we look at a heuristic for using classes in Python, with
   examples from real-world code, and some things to keep in mind.

 * Why use an SQL query builder in the first place?  eight minute read
   
   This is the second article in a series about writing an SQL query builder in
   150 lines of Python, why I wrote it, how I thought about it, and the
   decisions I had to make. In this article, I talk about why I needed a query
   builder in the first place, with examples derived from real use cases I had
   for my feed reader library.

 * SQL query builder in 150 lines of Python  two minute read
   
   In this series, we examine an SQL query builder I wrote in 150 lines of
   Python, why I wrote it, how I thought about it, and the decisions I had to
   make. This article is a sneak peek of the series and the code.

 * Using a Makefile with .PHONY-only targets? Use a run.sh script instead  four
   minute read
   
   ... in which we look at an interesting alternative to Makefiles with
   .PHONY-only targets, and why I think it's cool.

 * hashlib: object supporting the buffer API required  three minute read
   
   In this article, you'll find out what Python hashlib "object supporting the
   buffer API required" TypeErrors mean, why do they happen, and what you can do
   about it.

 * Learn by reading code: Python standard library design decisions explained
   (for advanced beginners)  five minute read
   
   On your Python learning journey, you may have heard that a great way to get
   better is to read code written by other people. That's true, but finding good
   code to study is not easy, mostly because the design philosophy and the
   reasoning behind the code are rarely documented. The Python standard library
   is special in this regard: not only is the code open source, but the
   discussions around the design decisions are public, too.

 * Dataclasses without type annotations  six minute read
   
   ... in which we talk about the many ways of using Python dataclasses without
   type annotations (or even variable annotations!), and what this says about
   Python.

 * Deterministic hashing of Python data objects  10 minute read
   
   In this article, you'll learn how to calculate deterministic hashes for
   arbitrary Python data objects, stable across interpreter versions and
   implementations.

 * Struggling to structure code in larger programs? Great resources a beginner
   might not find so easily  four minute read
   
   Are you having trouble making the modules work together in a larger project?
   Have you tried looking at popular projects as models, but were put off by
   their size and scope, or found it hard to see why they did the things they
   did? Resources about this do exist, but they're scattered all over, and might
   be hard to find for someone early in their programming journey.

 * Optimizing Advent of Code 2020 day 17  13 minute read
   
   ... in which we optimize our Advent of Code 2020 day 17 (Conway Cubes)
   solution, focusing on profiling and optimizing existing code, in a way that
   helps you translate those skills to your regular, non-puzzle coding. With a
   touch of code generation and some help from PyPy, we end up with a 65x
   improvement.

 * Solving Advent of Code 2020 day 17 by not solving it  16 minute read
   
   ... in which we solve the day 17 problem from Advent of Code 2020, Conway
   Cubes, in a generic way, focusing on testing, refactoring, and idiomatic
   Python, in a way that helps you translate those skills to your regular,
   non-puzzle coding.

I also maintain reader, a Python feed reader library. Every once in a while, I
summarize the latest changes here:

 * reader 2.11 released
 * reader 2.5 released
 * reader 2.0 released

home ∙ feed ∙ about ∙ © 2021 lemon24