Interfacing Python and C: The CFFI Module
How to use Python’s built-in CFFI module for interfacing Python with native libraries as an alternative to the “ctypes” approach.
How to use Python’s built-in CFFI module for interfacing Python with native libraries as an alternative to the “ctypes” approach.
An overview of the three main ways to reverse a Python string: “slicing”, reverse iteration, and the classic in-place reversal algorithm. Also includes performance benchmarks.
Learn advanced patterns for interfacing Python with native libraries, like dealing with C structs from Python and pass-by-value versus pass-by-reference semantics.
Learn a simple trick for keeping your Python code organized and maintainable—even as a project grows over time.
Do you have to be good at math to be a good programmer? Should you pursue a computer science career if you’re bad at math?
An end-to-end tutorial of how to extend your Python programs with libraries written in C, using the built-in “ctypes” module.
Generators are a tricky subject in Python. With this tutorial you’ll make the leap from class-based iterators to using generator functions and the “yield” statement in no time.
A tutorial on Python’s advanced data unpacking features: How to unpack data with the “=” operator and for-loops.
How and why to implement Python “to string” conversion in your own classes using Python’s “repr” and “str” mechanisms and associated coding conventions.
Understanding iterators is a milestone for any serious Pythonista. With this step-by-step tutorial you’ll understanding class-based iterators in Python, completely from scratch.
A step-by-step tutorial on the three main ways to reverse a Python list or array: in-place reversal, list slicing, and reverse iteration.
How to implement records, structs, and “plain old data objects” in Python using only built-in data types and classes from the standard library.
The various meanings and naming conventions around single and double underscores (“dunder”) in Python, how name mangling works and how it affects your own Python classes.
What is the Python programming language used for in the real world, and when is using Python the right choice?
How to implement a stack data structure (LIFO) in Python using built-in types and classes from the standard library.
In the fourth (and final) class in this series you’ll learn how to make your Python programs interactive by letting them react to user input.
In part three of this four-part Python introduction you’ll see how to teach your program how to make decisions with conditionals and if-statements.
How to implement a FIFO queue data structure in Python using only built-in data types and classes from the standard library.
In part two of this four-part Python introduction you’ll see how to write reusable “code building blocks” in your Python programs with functions.
How to implement mutable and immutable set and multiset (bag) data structures in Python using built-in data types and classes from the standard library.
In this four-part introduction for new programmers you’ll learn the basics of programming with Python using step-by-step descriptions and graphical examples.
Need a dictionary, map, or hash table to implement an algorithm in your Python program? Read on to see how the Python standard library can help you.
What are the various ways you can implement a priority queue in Python? Read on and find out what the Python standard library has to offer.
In this article series we’ll take a tour of some fundamental data structures and implementations of abstract data types (ADTs) available in Python’s standard library.
Understanding decorators is a milestone for any serious Python programmer. Here’s your step-by-step guide to how decorators can help you become a more efficient and productive Python developer.
PyPI, the Python packaging repository, just crossed 100,000 third-party packages in total the other week. That’s an overwhelming number of packages to choose from.
Python’s functions are first-class objects. You can assign them to variables, store them in data structures, pass them as arguments to other functions, and even return them as values from other functions.
Pythonize your C-style “for” and “while” loops by refactoring them using generators and other techniques.
The “with” statement in Python is regarded as an obscure feature by some. But when you peek behind the scenes of the underlying Context Manager protocol you’ll see there’s little “magic” involved.
In this tutorial you’ll learn how to set up Python and the Pip package manager on Windows 10, completely from scratch.
Python comes with a specialized “namedtuple” container type that doesn’t seem to get the attention it deserves. It’s one of these amazing features in Python that’s hidden in plain sight.
An introduction to “lambda” expressions in Python: What they’re good for, when you should use them, and when it’s best to avoid them.
Is Python worth learning? We’ve interviewed experts and surveyed the job market to identify the key reasons why you should learn Python today.
Remember the Zen of Python and how there should be “one obvious way to do something in Python”? You might scratch your head when you find out that there are *four* major ways to do string formatting in Python.
How to use assertions to help automatically detect errors in your Python programs in order to make them more reliable and easier to debug.
One of my favorite features in Python are list comprehensions. They can seem a bit arcane at first but when you break them down they are actually a very simple construct.
Python has two operators for equality comparisons, “is” and “==” (equals). In this article I’m going to teach you the difference between the two and when to use each with a few simple examples.
Python 3.6 adds a couple of new features and improvements that’ll affect the day to day work of Python coders. In this article I’ll give you an overview of the new features I found the most interesting.
Let’s pry apart this slightly unintuitive Python dictionary expression to find out what’s going on in the uncharted depths of the Python interpreter.
In Python code reviews I’ve seen over and over that it can be tough for developers to format their Python code in a consistent way: extra whitespace, irregular indentation, and other “sloppiness” then often leads to actual bugs in the program.
Ever witnessed a colleague make a refactoring to “clean up” some Python code only to make it worse and harder to understand?
In this third episode of my video code review series I take a look at a reader’s web scraping project and start adding some unit tests to it.
iTerm2 for macOS has a little known feature that lets you open files and folders simply by Cmd+Clicking on them in the terminal. Among other things, this is super handy for debugging tests.
This is the second episode of my video code review series where I record myself giving feedback and refactoring a reader’s Python code.
How to turn your Python scripts into “real” command-line commands you can run from the system terminal.
Python’s dictionaries have a “get” method to look up a key while providing a fallback value. This short screencast tutorial gives you a real-world example where this might come in handy.
This is a bit of an experiment – but you might find it interesting!
Sublime Text comes with a handy command line tool (“subl”) that lets you control Sublime Text from the terminal. In this 3 minute screencast I’ll show you how to setup the command and what you can do with it.
In this short screencast I’ll walk you through a simple code example that demonstrates how you can use custom exception classes in your Python code to make it easier to understand, easier to debug, and more maintainable.
When you ask for editor recommendations as a Python developer one of the top choices you’ll hear about is Sublime Text. In this post I’ll review the status of Python development with Sublime Text as of 2016.
This is my review of Zen Tabs, a Sublime Text 2/3 plugin that keeps your open editor tabs in check.
One of my friends works at a software company where all code changes must be reviewed before they’re deployed to production – I think that’s great. However, he finds that his team spends too much time discussing code style and formatting issues in their code reviews.
Let’s talk about using Python’s min and max functions on a list containing other lists. Sometimes this is referred to as a nested list or a lists of lists.
A quick video that demonstrates bpython, an awesome alternative Python interpreter.
Doing your first code review for something written by a senior member of your team is scary. As a novice programmer it’s easy to think that only beginning or intermediate developers struggle with this.
A quick screencast that shows you how to use Sublime Text as your Git editor. Super useful if you work with Git from the command line!
Let’s take a look at GitGutter, a Sublime Text 2/3 plugin that highlights lines modified since the latest Git commit.
Maybe you’ve been using Python for a while now and you’re starting to feel like you’re getting the hang of it. But one day you catch yourself thinking: “What about classes?”
It’s easy to accidentally write Python assert statements that always evaluate to true. Here’s how to avoid this mistake and catch bad assertions as part of your continuous integration build.
How to generate documentation for a RESTful API as part of your continuous integration build and then automatically deploy it to a website. Includes a full example project on GitHub.
When you make an HTTP OPTIONS request against an endpoint in a Django Rest Framework app you might be surprised about what you’ll find in the response to that request.
A great README file helps your project to stand out from the sea of open-source software on GitHub. In this article I go over the key elements every README for an open-source project should contain. It also includes a README.md template for use in your own projects.
I worked on a Python web app a while ago that was struggling with using too much memory in production. A helpful technique for debugging this issue was adding a simple API endpoint that exposed memory stats while the app was running.
Lately I’ve been doing a lot of remote collaboration with a team of designers and developers. This article explains a technique for sharing information that I found really helpful.
This productivity hack for developers might sound a little bit crazy, but I found that it works quite well.
Thankfully many software companies have adopted code reviews as a best practice these days. An overlooked aspect of how code reviews are conducted is how they can also affect the relationship between engineers negatively.
This is a tutorial about how to instrument a Node.js app with realtime metrics. We’ll use Datadog as a backend to do the monitoring together with the datadog-metrics library.
I love Hacker News. Taken with a grain of salt, it’s a great source of tech news. It’s also a very addictive source of tech news.
Display and share text in a large font, directly from your browser.
A collection of tools that I found useful for effective remote work as a software engineer, grouped by topic.
This article shows you how to use the pytest-osxnotify, a plugin for pytest that adds native Mac OS X notifications to the pytest terminal runner.
A while ago I gave a presentation at Mobify’s monthly Engineering Meeting where I spoke about various tactics that can help you become the best software developer you can be. I figured this may be useful to other folks as well and decided to share it in a blog post.
I keep two kinds of journals during my day to day work that I’d like to tell you about. They help me stay organized and motivate me to improve my skills as a developer.
Reading books is one of the best ways to improve your craftsmanship and to become a better software developer. This is a continuously updated list with my favourite programming books, sorted by topic. I link to the ebook version where possible but most books should be available made from dead trees as well.
Abstract Base Classes (ABCs) ensure that derived classes implement particular methods from the base class. In this tutorial you’ll learn about the benefits of abstract base classes and how to define them with Python’s built-in abc module.
Linked lists are fundamental data structures that every programmer should know. This article explains how to implement a simple linked list data type in Python using a functional programming style.
I recently started using Sublime Text 2 more and more as my main editor for Python development. This article explains my setup and some tweaks that make Python programmers happy.
For my Raspberry Pi internet radio project I needed a way to render text suitable for a low resolution monochrome LCD. This article describes how to render 1-bit text using FreeType and Python.
Paper and supporting materials for a talk I gave at the “1st European Workshop on Mobile Engineering” in February 2013 at RWTH Aachen.
I wrote a countdown timer extension for the Alfred application launcher for OS X. The extension is open-source, written in Python and uses Mountain Lion’s user notifications.
Many iOS applications contain an “invite your friends” feature. Ideally this feature should suggest people that the user is likely to invite. This article explains an App Store-legal method of guessing a user’s favorite contacts from their address book on iOS. The method is described in detail and a demo application is available for download.
Interfacing Python and C: The CFFI Module
How to Reverse a String in Python
Interfacing Python and C: Advanced “ctypes” Features
How to Structure Your Python Programs
I’m bad at math and I’ll never be a real programmer
Extending Python With C Libraries and the “ctypes” Module
What Are Python Generators?
Unpacking Nested Data Structures in Python
Python String Conversion 101: Why Every Class Needs a “repr”
Python Iterators: A Step-By-Step Introduction
How to Reverse a List in Python
Records, Structs, and Data Transfer Objects in Python
The Meaning of Underscores in Python
When to Use Python
Stacks in Python
Let’s Program with Python: Reacting to User Input (Part 4)
Let’s Program with Python: Conditionals and “if” Statements (Part 3)
Queues in Python
Let’s Program with Python: Functions and Lists (Part 2)
Sets and Multisets in Python
Let’s Program with Python: Statements, Variables, and Loops (Part 1)
Dictionaries, Maps, and Hash Tables in Python
Priority Queues in Python
Fundamental Data Structures in Python
Python Decorators: A Step-By-Step Introduction
Finding and Choosing Quality Python Packages
Python’s Functions Are First-Class
How to Make Your Python Loops More Pythonic
Context Managers and the “with” Statement in Python
Installing Python and Pip on Windows
Writing Clean Python With Namedtuples
Lambda Functions in Python: What Are They Good For?
Why Learn Python? Here Are 8 Data-Driven Reasons
The 4 Major Ways to Do String Formatting in Python
Assert Statements in Python
Comprehending Python’s Comprehensions
The Difference Between “is” and “==” in Python
Cool new features in Python 3.6
A Python Riddle: The Craziest Dict Expression in the West
How code linting will make you awesome at Python
A Python refactoring gone wrong
Python Code Review: Unplugged – Episode 3
Click & jump to any file or folder from the terminal
Python Code Review: Unplugged – Episode 2
How Do I Make My Own Command-Line Commands Using Python?
Using get() to return a default value from a Python dict
Watch me do a “live” Python code review for a reader
How to use Sublime Text from the command line
Make your Python code more readable with custom exception classes
Sublime Text for Python development — My 2016 review
Sublime Text plugin review: Zen Tabs
Should you call out code style issues in a code review?
How to use Python’s min() and max() with nested lists
A better Python REPL: bpython vs python
Should you worry about code reviewing someone more experienced than you?
Using Sublime Text as your Git editor
Sublime Text plugin review: GitGutter
6 things you’re missing out on by never using classes in your Python code
Catching bogus Python asserts on CI
Generate and host your API documentation for free with open-source tools
How to stop Django Rest Framework from leaking docstrings into OPTIONS responses
How to write a great README for your GitHub project
Debugging memory usage in a live Python web app
Remote work tip: Keeping your team in the loop with screencasts
Remote work tip: Rubber ducking with a journal
7 ways to avoid aggravation in code reviews
Monitoring your Node.js app with Datadog
Can’t keep up? Read Hacker News without wasting tons of time
Introducing my new utility website: large-type.com
Remote work productivity tools for software development
OS X notifications for your pytest runs
How to become a better software developer
Keep journals to become a better developer
Software engineer reading list: My favourite books about programming
Abstract Base Classes in Python
Functional linked lists in Python
Setting up Sublime Text for Python development
Monochrome font rendering with FreeType and Python
Towards Automated Detection of Mobile Usability Issues
A countdown timer extension for Alfred
Guessing a user’s favorite contacts on iOS
Some of the best content I post is email only. Join over 18,144 other Python developers on my (free) weekly newsletter →
📰 Learn More »