Cheat Sheets

A collection of the many Python cheat sheets within Python Morsels articles and screencasts.

13 articles · 2 hr 20 min read
4 screencasts · 17 min watch
01
Python's String Methods
14 min read

Python's strings have dozens of methods, but some are much more useful than others. Let's discuss the dozen-ish must-know string methods and why the other methods aren't so essential.

Read
Read
02
Built-in Functions
27 min read

Python's built-in functions list includes 71 functions now! Which built-in functions are worth knowing about? And which functions should you learn later?

Read
Read
03
Python f-string tips & cheat sheets
13 min read

Python's string formatting syntax is both powerful and complex. Let's break it down and then look at some cheat sheets.

Read
Read
04
Converting a string to a datetime
4 min read

The datetime.strptime class method can parse a date/time string into a datetime object.

Read
Read
05
Python's pathlib module
12 min read

Python's pathlib module is the tool to use for working with file paths. See pathlib quick reference tables and examples.

Read
Read
06
Python Big O: the time complexities of different data structures
9 min read

The time complexity of common operations on Python's many data structures.

Read
Read
07
Python's many command-line utilities
16 min read

Every command-line tool included with Python. These can be run with python -m module_name.

Read
Read
08
breakpoint: debugging
6 min read Screencast available

Need to troubleshoot an error in your Python code? Use Python's built-in breakpoint function to launch the Python debugger.

Read
Read
09
reduce() in Python and why to avoid it
4 min read Screencast available

Python's reduce function can "reduce" an iterable to a single value. But the reduce function is often more hassle than it's worth.

Read
Read
10
Every dunder method
16 min read

An explanation of all of Python's 100+ dunder methods and 50+ dunder attributes, including a summary of each one.

Read
Read
11
File modes
5 min read Screencast available Premium

What are Python's file modes, what are the differences between them, and which ones are actually worth using?

Read
Read
12
Setting default dictionary values
7 min read Screencast available

There are many ways to set default values for dictionary key lookups in Python. Which way you should use will depend on your use case.

Read
Read
13
Arithmetic Dunder Methods
8 min read Premium

What operators are overloadable in Python? And how does operator overloading work with each of the different types of operators?

Read
Read

Continue exploring

Profile picture of Trey

Learn something new about Python every week

My name is Trey Hunner. I publish new Python articles and screencasts every week through Python Morsels. If you want to learn something new about Python every week, join Python Morsels!

Join Python Morsels ✨