Commonplace

Things I've learned, passages I've collected, and short notes of my own.

2026

Be Guided by Beautylink ·

A guiding principle from the late, great Jim Simons.

Visit simonsfoundation.org

Bool Is a Subclass of Int in Pythonnote ·

In Python, bool is a subclass of int: True is the integer 1 and False is 0. So isinstance(True, int) is True, and True + True == 2 (PEP 285).

Read the note

Marking End of Positional Parameters in Pythonnote ·

A bare * in a Python function signature marks the end of positional parameters. Everything after it is keyword-only: callers must pass it by name.

Read the note

Bond Prices and Yields Move Inverselynote ·

A bond pays a fixed coupon, so when its market price falls, the return a new buyer gets (its yield) rises. "Prices fall" and "yields spike" are the same event seen from two sides.

Read the note

Packaging a Python CLI Tool for Homebrewnote ·

To package a Python CLI tool for Homebrew, create a GitHub tap, generate a formula using homebrew-pypi-poet, add tests, and optionally submit to Homebrew core for pre-compiled bottle distributions.

Read the note

Global Installation Using Pipxnote ·

pipx installs and runs Python CLI tools in isolated environments, ensuring version conflicts don't break system packages.

Read the note

Felix Culpaquote ·

"O felix culpa quae talem et tantum meruit habere redemptorem"
(O happy fault that earned for us so great, so glorious a Redeemer.)

— Latin phrase, Catholic Paschal Vigil Mass Exsulte

In Latin, Felix means “happy”, “lucky”, or “blessed”; culpa means “fault” or “fall”. This phrase felix culpa comes from catholic tradition, meaning “happy fault”, refers originally to the death and resurrection of Jesus Christ.

2024

Assert Statements Are Removed When Python Runs With -Onote ·

assert is for checking your own assumptions while developing, not for guarding production code: Python strips every assert statement when it runs with optimizations on, so the check silently disappears.

Read the note

Assigning to a Variable Anywhere in a Function Makes It Local in Pythonnote ·

A variable that a function only reads is looked up in the enclosing scopes. But if the function assigns to it anywhere in its body, Python treats it as local for the whole function, so reading it before the assignment raises UnboundLocalError.

Read the note

Mutable Default Arguments Are Shared Between Calls in Pythonnote ·

Default argument values are evaluated once, when the def statement runs, not on every call. A mutable default such as [] is therefore the same object on every call, and changes to it pile up.

Read the note

String Hashes Change Between Python Runsnote ·

hash() of a str or bytes gives the same result within one process, but a different one in the next run, because Python salts it with a random value chosen at startup. Never store or share hash() results; use hashlib when you need a stable digest.

Read the note

Subclasses Read Class Variables From Their Parent Until They Set Their Ownnote ·

A class variable lives in the namespace of the class that defines it. A subclass that doesn't set the variable itself reads it from its parent, following the method resolution order, so changing the parent's value changes what the subclass sees.

Read the note