Python Snippets Assignment expressions in Python Learn about Python's new assignment expression syntax and walrus operator. Assignment expressions can cut down on boilerplate code and improve efficiency!
Python Snippets Python's namedtuples Learn how to use the collection module's namedtuples to make your Python code even more clear and readable!
Python Snippets Python's divmod Function Learn all about Python's divmod function, which allows us to easily perform floor division and modulo operations in one go!
Python Snippets Python's format Function You may be familiar with Python's format method, but what about the format function? Learn to use Python's formatting language without string interpolation!
Python Snippets Python's Partition Method for Strings In this post we cover a lesser known string method called partition. It has a lot of similarities to split, but there are some interesting differences.
Python Snippets Formatting Integers in Different Bases in Python In this post we dive deeper into Python's formatting syntax, learning about displaying numbers in different bases. We also make a neat colour converter too!
Python Snippets Nested String Interpolation in Python In this post we continue looking at formatting, this time exploring nested string interpolation, which we can use to dynamically set formatting options.
Python Snippets Formatting Numbers for Printing in Python Learn how to leverage Python's detailed formatting language to control how numbers are displayed in your applications.
Python Snippets Python's "Ternary Operator" Learn about conditional statements in Python: a slightly obscure bit of syntax that allows for succinct conditional logic, particularly during assignments.
Python Snippets Generating a Collection of Random Numbers in Python In this post we learn about choices and sample: two useful functions in the random module used for generating collections of random values.
Python Snippets Updating Python Dictionaries In this snippet post we look at the update method for dictionaries. We can use update to change several values at once or extend dictionaries with new keys.
Python Snippets Extending Python Lists In this week's Python snippet post we look at the extend method for lists. Extend works a lot like append, but allows us to append many values at once.
Python Snippets Python Dictionaries and Loops In this post we cover various ways we can iterate over dictionaries. Learn how to use the items and values methods to write more Pythonic loops with dicts.
Python Snippets Python's zip_longest Function zip is an incredibly powerful tool, but it has its limitations. Learn about zip_longest so you can zip collections of any length without losing data!
Python Snippets Using zip in Python Python's zip function is extremely powerful and can simplify your code greatly, particularly when working with multiple iterables at the same time. In this post we cover a few ways to use it!
Python Snippets A Closer Look at Python's Print Function Print is one of the first functions we encounter when learning Python, but it can do a lot more than say "Hello, world!". Learn about print's other options and master this common function!
Python Snippets Python Easter Eggs This week we take a look at some of Python's hidden Easter eggs, including perhaps the most important module in all of Python: antigravity.
Python Snippets Python Deques Deques are a very handy collection type from the built-in "collections" module. They extend the functionality of lists and give us a couple more useful methods. Learn about them in this post!
Python Snippets Python Itertools Part 2 - Combinations & Permutations This week we continue our look at the itertools module, this time covering the permutations and combinations functions.
Python Snippets Python Itertools Part 1 - Product The itertools module contains a bunch of handy functions. Here we take a look at product, which can serve as a replacement for complex comprehensions.
Python Snippets Python's symmetric_difference Method for Sets In this Python snippet post we cover a lesser known set method: symmetric_difference.
Python Snippets Python Comprehensions with Conditionals In this snippet post we show you how to add conditional clauses to your list comprehensions. Once you know how to use it, this kind of filtering is very powerful.
Python Snippets List Comprehensions in Python Learn how to use Python's list comprehension syntax: an awesome, Pythonic tool for creating new lists from existing iterables.
Python Snippets Python's Enumerate Function In this Python snippet post we take a look at the enumerate function: a vital tool for creating Pythonic loops.
Python Snippets Python Set Operators In this post we cover shorthand operators for performing set operations in Python. We'll look at the three most common ones: union, intersection, and difference.