Skip to main content

December 2026

Every post published in December 2026, newest first. Pick a day to jump straight to it.

Posts
410
Topics
77
Reading time
40 h
Active days
3

Posts 181–210 of 410 · December 3, 2026

Page 7 of 14

Thursday, December 3, 2026

30 of 232 posts

  1. How to Accept Any Type in a Python Type Hint with typing.Any

    typing.Any marks a parameter, variable or dictionary value that can hold any type, such as a settings dict of strings, numbers and flags. A describe() function that takes Any, with real output from Python 3.15.2.

  2. How to Call a Function by Its Name in Python with a Dictionary

    Map names to functions in a dictionary, look a name up with .get() and call what you find, or handle the name that isn't there. Two actions and one unknown name, with real output from Python 3.15.2.

  3. Fixed: "JWT Claims Set must be a top-level JSON object" in jose for a PyJWT Token

    A Node.js service using jose rejected a token from a Python service with "JWT Claims Set must be a top-level JSON object". PyJWT had written float('nan') into the payload as NaN, which JSON doesn't allow. Sending null, and a strict JSON encoder, fix it.

  4. How to Log an Exception with Its Traceback in Python with logger.exception

    Inside an except block, logger.exception() logs your message at ERROR level followed by the full traceback, and the program carries on. A division by zero caught and logged, with real output from Python 3.15.2.

  5. How to Subtract from a Variable in Python with Augmented Assignment (-=)

    x -= 5 subtracts 5 from x and stores the result back in x, in one statement. A refund reduced by a shipping fee, plus the =- typo and the errors -= gives on a missing name or a string, with real output from Python 3.15.2.

  6. How to Delete Items from a List in Python with del

    del removes a list item by its position, or a whole range of items with a slice such as items[2:], changing the list in place. A packing list trimmed twice, plus the IndexError and SyntaxError del can give, with real output from Python 3.15.2.

  7. How to Make a String Uppercase in Python with upper()

    str.upper() returns a copy of a string with every letter in capitals and leaves the original unchanged. A discount code made uppercase and a typed code checked with strip() and upper(), with real output from Python 3.15.2.

  8. How to Check If a Value Counts as True or False in Python with bool()

    bool() shows whether Python treats a value as true or false: 0, empty strings, empty lists and None are false, almost everything else is true. Seven values tested, plus why bool("False") is True, with real output from Python 3.15.2.

  9. How to Reverse a Condition in Python with not

    Turn a Python condition around with the not operator: test for an empty list, a False flag or a failed comparison, see which values count as false, and avoid writing ! from other languages, with real output from Python 3.15.2.

  10. How to Create a Custom Exception in Python

    Define a class that inherits from Exception, raise it with a message when your own rule is broken, and catch exactly that error by name. An out-of-stock error for a small order function, with real output from Python 3.15.2.

  11. How to Check If More Than N Days Have Passed in Python with timedelta

    Compare the gap between two dates with timedelta(days=N) to check whether a deadline has passed. A 30-day return window checked for two deliveries, plus the TypeError a plain number gives, with real output from Python 3.15.2.

  12. How to Check a Value's Type in Python with isinstance

    Check whether a Python value is a str, int, list or dict with isinstance(), accept several types at once with a tuple, and see why True passes a check for int, with real output from Python 3.15.2.

  13. How to Count the Days Between Two Dates in Python

    Subtract one datetime.date from another and Python gives you a timedelta, whose .days is the number of days between them. An order and its delivery 18 days apart, with real output from Python 3.15.2.

  14. Fixed: Access to script at 'file:///…' from origin 'null' has been blocked by CORS policy

    A web page opened straight from the disk didn't run its script, and Chrome's console said "Access to script at 'file:///…' from origin 'null' has been blocked by CORS policy". Why a script tag with crossorigin can't load over file://, from MDN, and the one-line local web server that fixes it.

  15. How to Delete a File in Python with Path.unlink

    Path.unlink() deletes a file, and missing_ok=True stops it from raising FileNotFoundError when the file is already gone. Create a draft file, delete it, and delete it again safely, with real output from Python 3.15.2.

  16. How to Check Which Python Type Each SQLite Value Comes Back As

    SQLite stores NULL, INTEGER, REAL, TEXT and BLOB, and sqlite3 turns them into None, int, float, str and bytes. Store one value of each, plus True, and read their Python types back, with real output from Python 3.15.2.

  17. How to Catch SQLite Errors in Python with sqlite3.Error

    except sqlite3.Error catches every error the sqlite3 module raises, and the exception's class and sqlite_errorname tell you which one it was. A missing table and a duplicate value, caught by one except, with real output from Python 3.15.2.

  18. How to Generate a Subresource Integrity (SRI) Hash for a Script in the Terminal

    Make the sha384 hash for a script tag's integrity attribute with openssl dgst and openssl base64 on macOS and Linux, or with SHA384.HashData in PowerShell 7.6, then watch the browser run the script, block it when the file changes, and run it again with a new hash.

  19. How to Get the ID of a Row You Just Inserted in Python with lastrowid

    After an INSERT with execute(), cursor.lastrowid holds the id SQLite gave the new row. Two notes saved and numbered, plus what lastrowid holds after executemany() and after a SELECT, with real output from Python 3.15.2.

  20. How to Commit or Roll Back SQLite Changes in Python with a with Block

    Put SQLite changes inside with connection: and sqlite3 commits them when the block succeeds, or rolls all of them back when it raises an error. Two blocks of inserts, one that fails halfway, with real output from Python 3.15.2.

  21. How to Read SQLite Columns by Name in Python with sqlite3.Row

    Set connection.row_factory = sqlite3.Row and every row lets you read a column by its name, list the names with keys() and turn it into a dict. One book read by column name, with real output from Python 3.15.2.

  22. How to Run a SQL Script File in Python with sqlite3 executescript()

    executescript() runs several SQL statements in one call, such as a .sql file that creates tables and adds starting rows. A books.sql script read with pathlib and run against SQLite, with real output from Python 3.15.2.

  23. How to Put Python Values into a SQLite Query with ? Placeholders

    Write ? in the SQL where a value goes and pass the values as a tuple to execute(): sqlite3 binds them safely, apostrophes included. A book title with an apostrophe, inserted and found again, plus the errors an f-string and a missing comma give, with real output from Python 3.15.2.

  24. How to Add a Query String to a URL with QueryHelpers.AddQueryString in ASP.NET Core (C#)

    Build a URL with a query string in ASP.NET Core with QueryHelpers.AddQueryString: one value, several from a dictionary, and a URL that already has one, with spaces and & encoded for you and null values left out. Real output from a .NET 10 C# file-based app.

  25. How to Get One Row of a Query in Python with sqlite3 fetchone()

    fetchone() returns the next row of a SQLite query as a tuple, or None when there are no more rows. Look one book up, unpack its columns, and handle the None a missing book gives, with real output from Python 3.15.2.

  26. How to Get All Rows of a Query in Python with sqlite3 fetchall()

    fetchall() returns every row of a SQLite query as a Python list of tuples, and an empty list when nothing matches. Two books read into a list, plus the empty result, with real output from Python 3.15.2.

  27. How to Run a SQL Statement in Python with sqlite3 execute()

    connection.execute() runs one SQL statement against a SQLite database and returns a cursor you can loop over for the rows. Create a table, insert two books and read them back, with real output from Python 3.15.2.

  28. How to Add a Content-Security-Policy Header in ASP.NET Core (C#)

    Add a Content-Security-Policy header to every response of an ASP.NET Core app with a small app.Use middleware, then watch frame-ancestors 'self' let a page from the same site show it in a frame and block one from another site, with real curl output and the browser's console message. .NET 10 C#.

  29. How to Open a SQLite Database in Python with sqlite3.connect

    sqlite3.connect opens a SQLite database file, and creates it when it doesn't exist yet, or opens a temporary database in memory with ":memory:". A small script that opens library.db, with real output from Python 3.15.2.

  30. Fixed: The static asset was not found in the built time manifest in ASP.NET Core

    An ASP.NET Core app that serves wwwroot with MapStaticAssets warned "The static asset '/later.html' was not found in the built time manifest" for a page added while it ran. What the static assets manifest is, why the warning appears, and the restart that clears it, with real output from .NET 10 C#.