Posts tagged with "python" (385)
To return a value or not return a value
I believe operations that change things should always return values.
Top Terminal Tools
The tools I use in my day-to-day coding efforts in early 2026.
TIL: Using PygmentsRenderer with mistletoe as a partial
Another part of the process of switching from marked.js and python-markdown to just using mistletoe.
We moved to Manila!
We're going to be in Metro Manila, Philippines for a while, here's some of the details.
Writing tools to download everything
Using AI to help download photos so we can consolidate all our images into one place.
Adding Type Hints to my Blog
Using pyrefly to identify type failures on this site and then fixing one of them.
TIL: Default code block languages for mkdocs
Really useful for making inline code examples have code highlighting.
Visiting Tokyo, Japan from November 12 to 24
Our first time in a new country!
uv+just for testing multiple Python versions
In the old days we relied on tox and nox to test a Python project against multiple Python versions, now we can lean on uv+just. For most projects this keeps our configuration straightforward and reduces dependencies.
Using Asyncpg with FastAPI and Air
Asyncpg is the connector for PostgreSQL and asyncio-flavored Python. Here's how to use it without other libraries on FastAPI and Air projects.
Using pyinstrument to profile Air apps
Quick instructions for a drop-in Air middleware for identifying performance bottlenecks in Air apps
TIL: Loading .env files with uv run
Replacing python-dotenv with uv
Over Twenty Years of Writing Tools
A retrospective of over twenty years worth of writing tools that I've used to write online.
TIL: Setting environment variables for pytest
An easier way of doing it then modifying os.environ
TIL: Using SQLModel Asynchronously with FastAPI (and Air) with PostgreSQL
SQLModel is a really useful library for working with SQL databases in Python, built on top of SQLAlchemy and Pydantic. However, AFAIK there's no documentation supporting asynchronous operations for PostgreSQL, which can be a limitation when building high-performance web applications with FastAPI and Air.
TIL: Single source version package builds with uv (redux)
Tired of updating the version in multiple places before publishing a package update? Here's how Adam Johnson told me I should be doing it.
Unpack for keyword arguments
Keyword arguments can now be more narrowly typed by using typing.Unpack and typing.TypeDict.
TIL: How to type args and kwargs
A reduction in boilerplate confused me, the answer is that the type to define is the value in the containers.
TIL: Single source version package builds with uv
Tired of updating the version in multiple places before publishing a package update? Leery of using inspect.metadata to fetch the package? Here's how to have a single source of version using UV's build subcommand.
uv run for running tests on versions of Python
Using uv run with make to replace tox or nox for testing multiple versions of Python locally.
TIL: HTML 404 errors for FastAPI
For those times when FastAPI is serving web pages and users go to the wrong place.
Farewell to Michael Ryabushkin
In early May of 2025 Michael Ryabushkin (aka Goodwill) passed away. He was a great friend and an even better person. I will miss him dearly.
TIL: Exception.add_note
Adding extra info to exceptions the easy way.
Exploring flexicache
An exploration of using flexicache for caching in Python.
TIL: ^ bitwise XOR
How to mark a comparison of booleans as True or False using bitwise XOR.
TIL: Pipe operator for merging dictionaries
In Python 3.9 and later, the pipe operator | can be used to merge dictionaries.
TIL: webbrowser library
Python's built-in library for controlling browsers from Python
Using pyinstrument to profile FastHTML apps
Quick instructions for a drop-in FastHTML middleware for identifying performance bottlenecks in FastHTML apps
Pi Day
A really quick exploration of Pi in Python plus a call to action!
TIL: Undecorating a functools.wraps decorated function
Another reason to use functools.wraps!
Building a playing card deck
Today is Valentine's Day. That makes it the perfect day to write a blog post about showing how to not just build a deck of cards, but show off cards from the heart suite.
TIL: Typer commands defaulting to help
A more elegant way to display default help.
TIL: Every Jupyter notebook cell runs in an async loop
Obvious now that I think about it!
Fastcore L
An exploration of Fastcore's enhanced list-like structure
TIL: Using inspect and timeit together
Two libraries in Python's standard library that are useful for keeping load testing code all in one module.
TIL: yield from
A variant of the yield statement that can result in more concise code.
TIL: types.SimpleNamespace is a Bunch class
Did you know that Python's types library has a bunch class implementation? How did I not see this before?!
TIL: run vs source
Different ways to run bash commands that explains part of my frustration with bash over the years.
TIL: Using hx-swap-oob with FastHTML
How to have the injected content know where to go instead of assigning it from the form.
TIL: Arity
In logic, mathematics, and computer science, arity is the number of arguments or operands taken by a function, operation or relation.
TIL: How to reset Jupyter notebook passwords
For those times when you get locked out of a Jupyter notebook
TIL: Python's defaultdict takes a factory function
Create a dictionary-like object that takes a factory function so you have lots of control over what the default value can be.
TIL: Python Dictonary Merge Operator
Did you know there's a merge operator for Python dictionaries? I didn't until today!
TIL: Fractional Indexing
How to keep order of records without having to update all the records
TIL: Making pytest use Ipython's PDB
Once I've isolated a test failure to a very small set of failures I use this instead of running pytest directly. What it does on exception is start the IPython pdb interface.
TIL: SequentialTaskSet for Locust
How to get Locust to not bash your server like a robot.
TIL: Autoreload for Jupyter notebooks
How to skip having to restart your notebook on code changes.
Using locust for load testing
Quickstart guide for doing web application load testing with the Python powered locust library.
TIL: Using Python to removing prefixes and suffixes
How did I miss these functions getting added to Python?
Using Mermaid JS in Jupyter notebook
Useful for adding Mermaid charts of various types to Jupyter notebooks.
File Location Fixup
Writing a Jupyter notebook to clean up my blog's article locations
FastHTML form error handling
A pattern I have been exploring for handling form errors in FastHTML.
Mermaid charts!
My site now has mermaid charts! Many thanks to Imtiaz Khan!
Python CSV Cheatsheet
Here's a quick reference guide for Python's csv module. I use it periodicially, but not enough that I memorize the API.
TIL: Using FastHTML in Jupyter notebooks plus websockets
A simple websockets example hosted in a Jupyter notebook!
Practical Deep Learning for Coders: Lesson 1
I'm going through the fast.ai course by Jeremy Howard. This is the course notes for lesson 1.
Practical Deep Learning for Coders: Lesson 0
I'm going through the fast.ai course by Jeremy Howard. This is the course notes for lesson 0.
TIL: Parsing messy datetimes strings
How to convert inconsistent datetime strings into datetime objects.
London Tech Zero Hackathon on July 1 and 2!
On the 1st and 2nd of July is the first-ever London Tech Zero Hackathon, supported by Kraken Tech.
Rapidly creating smoke tests for Django views
A management command for quickly generating tests based off Django's URL routing mechanism.
TIL: Running UV outside a virtualenv
Breaking the rules to satisfy continuous integration.
Keynote at PyCon Lithuania 2024
My keynote and the first return to the homeland of Lithuania in over 100 years.
TIL: Writing decorators for classes
To my surprise writing decorators for classes is easier than for functions.
TIL: Forcing pip to use virtualenv
Necessary because installing things into your base python causes false positives, true negatives, and other head bangers.
Three Years at Kraken Tech
A summary of the past year as I finish my third year working for Kraken Tech, an Octopus Energy Group subsidiary.
TIL: Autoloading on Filechange using Watchdog
Using Watchdog to monitor changes to a directory so we can alter what we serve out as HTTP.
TIL: Fixing YAML
Here's how to prettify YAML across your projects.
TIL: Capture stdout & stderr with pytest
How to capture printed text using pytest, something I wish I knew sooner.
TIL: Rich.console.status for slow processes
From the command-line a trick to inform users know the system hasn't died and they should wait until it is done.
TIL: Poetry PyPI Project URLS
Adding sidebar links to PyPI projects powered by Poetry
TIL: pytest with breakpoints
Injecting breakpoints into a failing pytest run
PyPI Project URLs Cheatsheet
The PyPI project URLs spec is defined only in code. Here's my cheatsheet explaining how to configure them. I'll update this as I learn more (suggestions welcome!). Examples in several formats.
Converting from bleach to nh3
Bleach is deprecated, here's how to come close to replicating bleach.clean() with no arguments with nh3.
AWS Requests Auth
AWS signature version 4 signing process for the python requests module.
Cookiecutter Options Pattern
A technique I've used for years yet often forget. Placing it here for easy reference.
Programming languages I've learned
Starting as an adolescent I've been learning programming languages. Here's a list of the ones I've learned.
Converting Markdown Headers to Checklist
For those times when you write out a long markdown document that you want to convert to a checklist.
Configuring Sphinx Auto-Doc with projects having Django dependencies
How to make it so projects with Django as a dependency benefit from Sphinx's auto-documentation features.
Practice Python Web Projects
Python web projects taken from my personal history to practice on to improve your skills.
Live Discussion with Sebastián Ramírez (Tiangolo)
I have a friendly live discussion with Sebastián Ramírez, creator of FastAPI, Typer, SQL Model, and more.
Pip Installing Dependencies Into Conda Envs
People think Conda is challenging to use or doesn't work with pip, when in truth it is easy and just works everywhere.
Blogger to Markdown Script
Converting hundreds of posts from blogger to markdown
Sendowl Consolidation Script
Unifying our sendowl accounts into one
More Married
In honor of Valentine's Day, this script calculates how long you've been married (or other types of relationships) in relation to how long you've known each other
Speaking at Python Web Conf
My first public conference talk in three years
Autodocumenting Makefiles
Make Your Makefiles Make Your Day!
Exploring the Bunch Class
Bunch classes are very powerful, and with great power comes great responsibility
What's the Ultimate Reason for Working at Octopus Energy?
Wherin I conclude my discussion about why I work at Octopus Energy.
What's the Best Thing about Working for Octopus Energy?
An in-depth discussion about my employment at Octopus Energy.
Recap of 2020 and Resolutions for 2021
August 2020 Courses
All the live, online, interactive courses I'm teaching in the month of August 2020.
I'm Teaching A Live Online Django Crash Course
Django Slug + ID URL Design
How to combine slugs and IDs to make a a human readable unique URL design.
Two Scoops of Django 3.x Released
The book about best practices for the Django Web Framework, Two Scoops of Django, has been revised, updated, and expanded for versions 3.0, 3.1, and 3.2.
Adding Metadata to PDFs
How to use Python to combine PDFs and then add metadata to them.
Our New Django Book Has Launched!
We wrote a beginner-friendly tutorial book for Django!
Feed Generator
Writing a Python script to generate my blog feed
Meeting Python Devs in Cancun
Python programming builds bridges across the world!
My Markdown Code Snippet Tester
Ensuring that code in my articles actually works.
Stop Using Executable Code Outside of Version Control
Fighting the local_settings.py antipattern
Authenticating via JWT using Django, Axios, and Vue
Getting DRF, JWT, Axios, and Vue to play nice
Writing A New Blog Engine
Where I describe why and how I wrote a new blog engine
Implemementing Manual Schema with Django REST Framework
Implementing a manual schema in Django REST Framework
When to Use MongoDB with Django
Short answer is you don't use MongoDB with Django. Read on for the specifics.
Hola, PyCon Colombia!
We're going to PyCon Colombia!
2018 New Years Resolutions
My New Year's resolutions for 2018.
Two Scoops of Django Birthday Giveaway
My 2017 birthday giveaway contest.
Two Scoops of Django 1.11 Is Printed!
Using Python and Google Docs to Build Books
Using Python to combine multiple Google docs into one cohesive whole that can be published as a book.
Python F-Strings Are Fun!
Two Scoops of Django 1.11 is Out!
Code, Code, Code
I'm often asked by new programmers how they can forge a path into using their skills professionally. Or how they can get better at writing software. In this article I share the secret master-level method to improvement.
Pretty Formatting JSON in the Django Admin
How To Create Installable, Reusable Django Packages
Intensive Django Training with the US Air Force
Titlecasing Markdown Headers with Python
Why Doesn't Python Have Switch/Case?
Django Girls Ensenada 2015
Markup Language Faceoff: Lists
Two Scoops of Django 1.8 is Out!
Phasing Out Django Packages APIv1 & APIv2
Setting up LaTeX on Mac OS X
Python Decorator Cheatsheet
I can never remember the syntax for writing decorators. I always have to look it up. Worse, I always have to remember where to look to find references. Hence the reason for this article. I'll never lose this reference: It's on my laptop and the internet.
Building Conda Packages for Multiple Operating Systems
I did an Au Batido in 2014, now what?
setup.py tricks
Adding Django form instance attributes
Sometimes in the `clean()`, `clean_FOO` or `save()` methods of a Django form, you need to have additional form instance attributes available. A sample case for this is having `user_id` available. This is a simple example of how to do it in Class-Based Views.
Announcing BarCamp Django SF!
Hola, Argentina!
Want to work for Eventbrite?
Want to work for Eventbrite? (part 2)
cached-property: Don't copy/paste code
Jinja2 Quick Load Function
Python Partials are Fun!
Beginner's Guide to PyCon 2015
Two Scoops of Goblins
Memories of Malcolm
Docstrings and Various Python Objects
Announcing Two Scoops of Django 1.6!
awesome-slugify: Human-readable URL slugs from any string (part 2)
awesome-slugify: Human-readable URL slugs from any string
pytest: no-boilerplate testing (part 3)
pytest: no-boilerplate testing (part 2)
pytest: no-boilerplate testing
New Year's Resolutions for 2014
Cookiecutter: Project Templates Made Easy
Cookiecutter makes creating and maintaining project templates easy and intuitive.
Made Up Statistics
Travel Tips for Geeks: Preventing Theft
My experiences with Django and Python 3
EuroPython Intro to Django Workshop
Core Concepts of Django ModelForms
The concepts behind Django's model forms can be boiled down to six items.
Tools we used to write Two Scoops of Django
Filepicker.io and South
Two Scoops of Django is in print!
Generating NCX files with Python
Annotated History of My Most Used Shell Commands
Fixing Python's String class
Core Concepts of Django Forms
The concepts behind Django's non-model forms can be listed in just three items.
Overloading Django Form Fields
How to overload Django form fields in an extensible way.
New Year's Meme 2013
Exceptions as Decorator Arguments
Python Indie Bundle Cyber Monday Sale
Python Yields are Fun!
The Easy Form Views Pattern Controversy
PyCon Tutorial: Wiring Up Django Packages
Beginner's Guide to PyCon 2013 Part III
We are not using PayPal
Two Scoops of Django 1.5 Beta Released
Beginner's Guide to PyCon 2013 Part II
Beginner's Guide to PyCon 2013 Part I
Two Scoops of Django FAQ
Our Django Book Has Launched
New Year's Resolutions for 2013
2012 resolution summary
New Year's Python Meme 2012
Developer Time
Stay with the Django CBV defaults!
Case Study: URL Design for petcheatsheets.com
Django GetOrCreateView
Probably the first article outside the official docs on how to use the Django CBV form_valid method. Written in 2012 and still accurate in 2023!
Los Angeles Open Source Sprint on Nov 4th!
We need more PyCon US 2013 submissions!
Installing Pycairo on Mountain Lion
Thoughts on my stack
Python dictionary as a class
A Public Service Message to the Python Community
PyCon 2013 Talks/Tutorials I want to see
Python dictionary vs JavaScript object: Dynamic Keys
Django Requirements 2012-08-15
Curiosity has landed!
Attaching custom exceptions to functions and classes
Django Update View Without Slug in the URL
July 15th, 2012 LA Open Source Recap
Simple HTTP Basic Auth Wall
PyCon Philippines 2012 Day 2
A wonderful end to a wonderful event.
PyCon Philippines 2012 Day 1
The first day of the first PyCon Philippines!
Announcing PyCon Philippines!
Django Class Based View: email form with CAPTCHA
Simple Django email form using CBV
May 12th, 2012 LA Open Source Recap
10 reasons to go to DjangoCon Europe
CSS Hacking to make my code samples legible
Choosing an API framework for Django
Django Requirements for a project
Los Angeles Open Source Sprint on May 12th!
Join us at DjangoCon Europe!
Choosing a new python based blog engine
Calendar About Nothing
Launching our API at PyCon 2012
The sorry state of Python OAuth providers
You should Heroku
I use this
PyCon Australia 2011 Review
My PyCon 2012 Schedule
Selected for PyCon StartUp Row
Parsing MongoDB URI
My blog is moved
django-uni-form end of life
Silicon Beach Hackercast
An attempt made long ago to create a podcast
Capoeira at PyCon!
Python Web Summit Questions needed!
How to justify attending PyCon sprints
Join the PyCon Early Birds program!
Tips for speaking
My SOPA boycott
Resolutions for 2012
New Year’s Python Meme
Evaluating which package to use
Announcing Consumer Notebook!
Made Up Statistics
The Story of Live-Noting
Redux: Python Things I Don't Like
Loving the bunch class
PyCodeConf 2011 Report
Conference Talks I want to see
Quick conferences report: Presentations
Responses to Github is my resume
Github is my resume
The Ultimate Django Tutorial Workshop
Python and Django class/hackathon!
I'm going to Pycon Australia!
Hollywood Hackathon Report
Do not upload dev releases at PyPI
Hollywood Hackathon on June 18th!
Python HTTP Requests for Humans
A couple great Pycon 2011 Talks
We won first place at Startup Camp LA!
I teach Python and Django
How NOT to interview Pythonistas
Are you looking for Python and Django Work?
Python Packages sprint on Sunday 4/10/2011
PyCon 2011 Sprint Report
Announcing Garbaginator!
PyCon 2011 Tutorial Report
I'll get you next time, Wesley Chun!
The Great PyCon Ribbon Game!
My tips for speaking
My Django tutorial at PyCon
My Pinax Solutions class at Pycon 2011
How to sell Python panel at Pycon
Los Angeles Open Source Hackathon
Why you should go to Pycon
Pinax Tutorial at Pycon 2011
Resolutions for 2011
Recap of 2010
Reactions to "Stupid Template Languages"
Stupid Template Languages
Release classifiers in distutils/pypi
A request for new pypi classifiers
More reasons to go to DjangoCon!
Getting excited about DjangoCon US!
Getting piston forms to play nicely with JSON
I want to talk to Jython and Iron Python developers
Apologies to the Python community
My little unit test trick
Steve Holden giving a talk on Python education
Moving away from DC
Leaving NASA
Pycon 2010 report III: Sprints
My report for the sprints of Pycon 2010. This isn't a general review of the sprints, just how it affected me.
Pycon 2010 report II
Eating my own Dog Food
What I don't like about Pycon
Learn something new every year
Reserve your low pycon price today!
Register for Pycon 2010 already!
2009 resolution summary
Recap of 2009
Python Wars
Code I'll reuse
What I love about Python
Pycon talks and tutorials
Djangonaut Lunch in Crystal City
Looking for work?
Pycon talk thoughts
Slides from DjangoCon 2009
Pycon talk proposal reminder
Show me your open source Django CMS
Best DjangoCon 2009 Day Ever!
I want to give a class or talk at Pycon 2010
NOVA-DUG August 19th summary
NOVA-DUG meeting notice for August 19th
NOVA-DUG scheduling
Turning away from CAPTCHA
NOVA-DUG meeting notice for July 8th
What happened to NOVA-DUG?
Thanks for San Francisco!
I don't like Integrated Development Environments
Eight things I don't like about python
DC Sprints location is changed!
DC sprints location is official!
Sweet spots of Plone
Finger method of judging graphic design
What I learned at Pycon 2009
Show me your open source Django blog application
NOVA-DUG meeting on Wednesday, April 15th, at 7:30 pm
Northern Virginia Django Users Group lives!
Django Dash worst concept contest
Jinja2 in zope
Forming a Northern Virginia Django User Group
Day 3 Pycon-09 talks I'm attending
Best Pycon 2009 Day Ever!
Day 2 Pycon-09 talks I'm attending
Day 1 Pycon-09 talks I'm attending
Pycon Tutorials attended by me
Heading off to Pycon 2009!
Looking for work?
Simplegraph Screen Capture
How to globally ignore .pyc files
Useful python code for blogspot users like me
Recap of 2008
Looking under the hood of Pinax
Compiling Python on Mac OS X 10.5 can be a pain
I've not quite done LAMP, or have I?
Thoughts on Python interfaces
I missed a class taught by Lennert Regebro?
Trials and Tribulations of avoiding vi
Funkload to be revisited!
Me Grok generate Add and Edit forms!
Ruby Security Problems
Umlizer lives!
Must use ubigraph
How not to build a view
Inheritence is fun!
Visit the Greater Lipsum Project at your own peril
Genius will be rewarded
To Shell is to love Python
I love graphing
The problem with comparing Pylons to Django
Feedparser does not work with Google App Engine
Import Soul
Sick but Ubuntu
Zed Shaw, YAML, Python Community
So what did I do on the website?
This looks interesting...
Need better charting for Python
Django at Pycon
Pycon Wrapup
Zed Shaw and me
Numpy Tutorial overview
2 days until Pycon and Chicago
Open source makes the world better
Pycon 2008!
Work things
Funkload + Matplotlib = charts!
Funkload Charting woes
SVN Versionator is dead
More on SVN Versionator
SVN versionator!
Reason #4293 why I'm happy to be out of ColdFusion
Python is the programming language of 2007!
The hard truth about Python
Playing with Trac, SVN, Apache, and LDAP
Capturing shell output in Python
Need to get into the habit of using Python sets
What is a real language?
Thoughts back in the day when
