RSSAmplifier

Blog

Invent with Python

inventwithpython.comRSS feed ↗100 posts

Latest posts

Fractal Art Maker for Python Turtle.py

Fractals are beautiful, self-similar patterns that can be created by a computer from very simple rules. My Fractal Art Maker package makes it easy to use Python's turtle.py package to draw your own. You don't need to know recursion, but you can read my free book, The Recursive Book of Recursion if you're curious. If you want to learn how to draw pictures with Python code, I also have The Simple…

Turtle Colors and RGB App

I've been working on turtle-related projects and I needed a simple, interactive, single-file Python program to explain RGB color values. I wrote this one up as part of my work writing a Simple Turtle Tutorial written in Wikipedia-style Simple English so it can be translated to non-English languages. You can download the app from PyPI and look at its code on its git repo

Automate the Boring Stuff Workbook Now Available for Preorder

" This workbook transforms Al Sweigart’s best-selling guide from a reading experience into a coding experience. Following Automate the Boring Stuff with Python chapter by chapter, this workbook will help you turn concepts into muscle memory through carefully designed exercises, projects, and real Python scripts." Preorder links: Direct From the Publisher (preferred) | Amazon | Barnes and Noble |…

Before/After Photo Alignment Web App

I created a web app for aligning before/after photos . Ony of my hobbies is picking up litter, and I'll post before/after photos to the r/detrashed subreddit:

List of 87 Programming Ideas for Beginners

After you've learned the basic concepts, the best way to improve your coding skills is to work on projects. You may not know enough to contribute to popular open source projects, but you can create small programs on your own. Here's a list of 81 projects suitable for beginners. They're short, can be done in any language, and don't require additional software library installation. These projects…

Web version of the 1985 'Maze' book by Christopher Manson, an inspiration for Blue Prince

I wrote some Python scripts to help me create the HTML web pages for an online version of Maze, a 1985 visual puzzle book by Christopher Manson that was a large inspiration for Blue Prince (my personal game of the year for 2025). I'm hosting it at https://inventwithpython.com/mazewebsite/

Recursive Fract-Al

For Halloween 2024, I made a Recursive Fract-Al costume. It was literally an exponential amount of work! The idea came to me when I was writing The Recursive Book of Recursion

A Complete List of Python Tkinter Colors, Valid and Tested

I needed a complete list of valid color names for Python's Tkinter package as part of my ButtonPad GUI framework development. The lists I found on the internet were either incomplete, buried under ads, and often just plain wrong. Here's a list of all 760 color names (valid and personally tested) for Python Tkinter.

Vibe Coding Experiment Failures

Over the past week I've been experimenting with vibe coding : asking LLMs such as ChatGPT, Claude, and Gemini write entire apps as if I had absolutely no programming ability at all. LLMs can easily solve programming challenges or interview questions. But I wanted to see how far the current LLMs can go when asked to make complete apps, and what kinds of failure patterns emerge. From the role of a…

Al Sweigart's Endorsements for PSF Board 2025

The nominees for the Python Software Foundation's Board of Directors 2025 election have been announced. You can find a full list on the nominees page . This year there are 4 seats open on the PSF Board. You can see who is currently on the board on the PSF Officers & Directors page . I'm pleased to announce I'm endorsing the following nominees: Abigail Dogbe, Archana Vaidheeswaran, Daniele Procida,…

The Recursive Leap of Faith, Explained

There is a phrase used when teaching recursion and recursive functions, leap of faith . In researching my book, The Recursive Book of Recursion , I found that most explanation of this technique were vague or even misleading. In this article, I'll go into what the leap of faith is and how it can help you write your recursive functions.

Recursive Functions To Anger Your CS Professor

Here are some recursive functions that are technically correct and technically recursive.

Audio, Video, and Webcams in Python (Lost Chapter from Automate the Boring Stuff)

The third edition of Automate the Boring Stuff with Python is now available for purchase or to read for free online . It has updated content and several new chapters, but one chapter that was left on the cutting room floor was "Working with Audio, Video, and Webcams" . I present the 26-page rough draft chapter in this blog, where you can learn how to write Python code that records and plays…

The TurtleSC Package for Python turtle.py Shortcuts

TurtleSC provides a mini-language of shortcut instructions to carry out turtle.py function calls, like 'f 100' instead of forward(100) . Git Repo , PyPI Project Page .

What is the difference between GitHub vs. GitLab vs Alternatives?

This article and its content were written, reviewed, and verified by a human, Al Sweigart. In my research I found that most "GitHub vs GitLab" articles are AI slop containing false or outdated information. I wrote this article with links to actual documentation pages, and not just copying what every other article on this topic says. For those who have heard of this "Git stuff," here's a summary of…

Procedurally Generating a Tic-Tac-Toe Zine with Python

At PyCon 2025, I handed out a pocket-sized zine that lets you play a procedurally generated choose-your-own-adventure version of tic-tac-toe. The zine itself is available as a PDF for viewing on your computer and a PDF for double-sided printing . Here's how I made it using Python.

Fabric.js Tutorial Part 6

Part 5 of a tutorial series on the Fabric.js canvas/graphics library for JavaScript, we'll learn how to change the size of shapes by scaling them with the scale() method. We'll also get some more practice drawing in general. We'll draw this forest:

Fabric.js Tutorial Part 5

Part 5 of a tutorial series on the Fabric.js canvas/graphics library for JavaScript, where we learn about grouping, cloning, and rotating shapes.

Fabric.js Tutorial Part 4

Part 4 of a tutorial series on the Fabric.js canvas/graphics library for JavaScript, where we learn about drawing with paths.round color of a canvas as well as the shapes fabric.Polygon and fabric.Line .

Fabric.js Tutorial Part 3

Part 3 of a tutorial series on the Fabric.js canvas/graphics library for JavaScript, where we learn how to set the background color of a canvas as well as the shapes fabric.Polygon and fabric.Line .

Fabric.js Tutorial Part 2

This is Part 2 of the Fabric.js tutorial canvas/graphics library for JavaScript, where we learn about Polyline shapes and styling shapes by drawing a gingerbread figure.

Fabric.js Tutorial Part 1

This is part 1 my tutorial series on the Fabric.js canvas/graphics library for JavaScript, where we learn about drawing basic shapes like rectangles, circles, and triangles to draw pine trees.

Make Lively Movement Animation with PyTweening's Tweening Functions

Tweening functions allow you to easily add many different styles of natural-seeming movement to the graphics in your program. In this blog post, you'll learn about how tweening functions can make more lively movement animations using Pygame and the PyTweening third-party library. Tweening functions apply to any programming language, but this tutorial has actual Python code for you to run and…

Book Review: Geometric Patterns with Creative Coding

4 stars. I came across Selçuk Artut’s Geometric Patterns with Creative Coding while researching several topics on computer-generated art for beginners. I admit, the single 1-star review for this book annoyed me enough to read and review. I’ve come away believing that this book certainly deserves wider and better attention than that.

What's New in the 3rd Edition of "Automate the Boring Stuff with Python"

The third edition is has new chapters, programming projects, and revised editing. The third party module coverage has been updated to the latest available version (including OpenPyXL). You can run pip install automateboringstuff3 to install the latest version of all modules covered in the book that are compatible with the book's code examples.

Using ChatGPT-4 to Review My Recursion Programming Book

My 2022 book, The Recursive Book of Recursion ( read online for free , buy direct from the publisher ) covers recursive algorithms, a notoriously tricky subject for programmers and computer science students. I feel like I did a good job writing it (and my editors at No Starch Press did an incredible job editing it), but I wondered how well Large Language Models (LLMs) like ChatGPT could understand…

Book Review: Python Distilled

5 stars. Python Distilled has a perfectly suited title: This book is for experienced programmers who want to learn Python and need the Python programming language's core syntax, standard library, and Pythonic idioms. However, if you're a developer who wants to add Python to your toolbox, I recommend Python Distilled as one of the first books you should read.

Book Review: Python in a Nutshell

5 stars. Python in a Nutshell is an excellent book for professional developers who have some experience with Python but want to take the leap to being a senior Python developer, Python in a Nutshell is required reading.

How to Install Pygame on Windows, macOS, and Linux

Installing Pygame on your computer is fairly straightforward, but there are a few potential bumps to be aware of.

Python Linter Comparison 2022: Pylint vs Pyflakes vs Flake8 vs autopep8 vs Bandit vs Prospector vs Pylama vs Pyroma vs Black vs Mypy vs Radon vs mccabe

As you can tell from the lengthy title, there are many linting tools for Python. Some of them have near-identical names as each other. In November 2022, I upgraded my text editor to Sublime Text 4 and then took the opportunity to spend a few hours reviewing all of the Python linters I could find. After personally reviewing all of them, I've selected the following as must-haves: Pyflakes, Mypy, and…

I Want To Help Everyone And I Will Fail

I like to program computers. An army of a million file clerks wouldn't be as productive as my laptop running the right code. And my house only has one bathroom so the line would be quite long too...

Installing Brython to Get Python in Your Browser

JavaScript is not the only programming language you can run in the browser. Brython is a Python interpreter implemented in JavaScript so you can run Python code in your browser. This lets you have a Python interactive shell without having to install Python. You can also write Python code to interact with the DOM and create browser apps just like you could with JavaScript. The primary downside is…

17 Online Python IDEs and Interactive Shells/REPLs

Installing Python is easy, but maybe you're on a smartphone/tablet, are on a library computer that doesn't let you install software, or can't install Python for some other reason. This article has a list of 10 free Python interpreters and interactive shells (also called REPLs) that you can access from a web browser.

How Computers Store Data with Binary Numbers

Programming and hacking in movies often involves streams of ones and zeros flowing across the screen. This looks mysterious and impressive, but what do these ones and zeros actually mean? You're probably aware that binary numbers (numbers written using only the two digits, zero and one) have something to do with computers but don't know why.

Is Python Compiled or Interpreted?

The short answer is: Python is interpreted. But it can also be considered compiled, both compiled and interpreted, and neither compiled nor interpreted. Read on to untangle these definitions.

How to Run Pip From The Python Interactive Shell

Installing Python modules with the pip tool is surprisingly hard to describe to beginners learning to code. There are several potential issues: multiple Python installations, virtual environments, PATH environment variable settings. You have to introduce command-line terminals and file system navigation, and the differences between Windows and Mac/Linux. However, there is a line of code you can…

Introducing Humre: Human-Readable Regular Expressions

Regular expressions (aka regexes) are a mini-language to specify a pattern of text to look for. However, regex syntax is composed of various punctuation marks that can be hard to remember. Humre is a Python module that gives a more human-readable syntax that works better with code editing tools. You can install Humre just like any other Python module with pip install humre and the full…

Which Al Sweigart Python Books Should I Start Reading?

I've been writing programming books for beginners since 2009. All of them are free to read online at InventWithPython.com Many people email me asking which of my books they should read, so I wrote this guide to help beginners get started with my free learning materials.

New Book: The Recursive Book of Recursion by Al Sweigart

My new programming book, the Recursive Book of Recursion, is released in August 2022. The book covers several classic recursive algorithms and breaks down recursion's fearsome reputation as a programming technique. The book has the code for its numerous programs in both Python and JavaScript. When you buy it direct from the publisher, No Starch Press , you'll receive a DRM-free ebook copy with…

How Many Recursive Cases and Base Cases Does a Recursive Function Need?

Let's look at a simple example of a recursive function to see what it needs at minimum.

Bootstrap 5 Boilerplate Code for New Web Pages

Here's the boilerplate that you can copy and paste when creating a new web page with Bootstrap 5.

Make Fractals in Python Turtle with the FractalArtMaker Module

Fractal Art Maker has been upgraded and is now covered in this new blog post.

How to Use Python 3.11's New TOML Parser, tomllib

Python 3.11 will include a TOML parsing module called tomllib . Let's learn what TOML files are (they're similar to JSON), how they're useful for configuration files, and how you can write Python code to read them.

Downloading Web Pages and Files in Python 3 and 2 Without the Requests Module

How to download web pages and files off the internet only using Python 3 and 2's standard library.

I Like Al Sweigart's Books, What Can I Read to Get Into Game Programming?

If you like my programming books, here's a few more resources you can use to get into video game development.

What Kind of Computer Do I Need to Learn Programming?

You don't need to buy a new computer to learn programming. It's a common misconception that you need a powerful computer to program. This guide will give you some hints to guide you in the right direction.

Book Review: Make Python Talk

Mark H. Liu’s “Make Python Talk” is a solid book for anyone who wants to leverage the power of the Python programming language to add speech capabilities to their programs. The chapters cover third-party libraries for speech recognition and text-to-speech in an engaging way.

Book Review: Serious Python

Serious Python by Julien Danjou is an excellent book for those who have gone through the "hello world" tutorials or those coming to Python from other programming languages, and want a book that teaches you not just how to write code, but how to write code the pythonic way.

Book Review: Tiny Python Projects

Writing for an intermediate audience is hard, but Ken Youens-Clark has nailed it with Tiny Python Projects. This is a great book for those who have dabbled with a few beginner Python tutorials but still feel like they don't "get" programming. The projects in this book are short and simple; perfect for beginners who want to get experience with actual programs instead of just code snippets.

How to Represent a 2D Grid in Python Code

This blog post examines different ways that Python lists and dictionaries can be used to represent a 2D data structure. I also write some test programs to measure the performance of each data structure.