Python Screencasts - Python Morsels

New Python screencasts released weekly. To keep up with new screencasts sign up for Python Morsels.

Screencast Topics

13 mins

Tuple Unpacking

It's tempting to reach for indexes when working with tuples, lists, and other sequences, but if we know the shape of the tuple we're working with, we can unpack it instead.

Tuple unpacking (aka "multiple assignment" or "iterable unpacking") is often underutilized by new Python programmers.

34 mins

Modules

Modules are the tool we use for breaking up our code into multiple files in Python. When you write a .py file, you're making a Python module. You can import your own modules, modules included in the Python standard library, or modules in third-party packages.

10 mins

Command-Line Programs

A .py file can be used as a module or as a "script" which is run from your operating system's command-line/terminal. Python is a great programming language for making command-line scripts.

15 mins

Variable Scope

Python has 4 scopes: local, enclosing, global, and built-ins. Python's "global" variables are only global to the module they're in. The only truly universal variables are the built-ins.

19 mins

Generator Expressions

List comprehensions make new lists. Generator expressions make new generator objects. Generators are iterators, which are lazy single-use iterables. Unlike lists, generators aren't data structures. Instead they do work as you loop over them.

12 mins

Properties

We don't use getter and setter methods in Python. Instead we make properties.

Properties allow us to customize what happens when you access an attribute and what happens when you assign to an attribute.

16 mins

Generator Functions

Generator functions look like regular functions but they have one or more yield statements within them. Unlike regular functions, the code within a generator function isn't run when you call it! Calling a generator function returns a generator object, which is a lazy iterable.

11 mins

Installing Python Packages

Python's standard library includes a lot of helpful modules. But often Python code depends on third-party packages. What are the best practices when working with third party packages in Python?

10 mins

Inheritance

Classes can inherit functionality from other classes in Python. Class inheritance can be helpful, but it can also be very complex.

48 mins

Decorators

Decorators are functions that accept functions and return functions. They're weird but powerful.

68 mins

Classes

Classes are a way to bundle functionality and state together. The terms "type" and "class" are interchangeable: list, dict, tuple, int, str, set, and bool are all classes.

You'll certainly use quite a few classes in Python (remember types are classes) but you may not need to create your own often.

40 mins

Looping

Unlike, JavaScript, C, Java, and many other programming languages we don't have traditional C-style for loops. Our for loops in Python don't have indexes.

This small distinction makes for some big differences in the way we loop in Python.

24 mins

Comprehensions

In Python it's very common to build up new lists while looping over old lists. Partly this is because we don't mutate lists very often while looping over them.

Because we build up new lists from old ones so often, Python has a special syntax to help us with this very common operation: list comprehensions.

45 mins

Dunder Methods

You can overload many operators, protocols, and bits of functionality on your Python objects by implementing dunder methods.

41 mins

Assignment and Mutation

Python's variables aren't buckets that contain things; they're pointers that reference objects.

The way Python's variables work can often confuse folks new to Python, both new programmers and folks moving from other languages like C++ or Java.

13 mins

Context Managers

A context manager as an object that can be used with Python's with blocks. You can make your own context manager by implementing a __enter__ method and a __exit__ method.

27 mins

Conditionals

Conditionals statements (if statements) are useful for making a branch in our Python code. If a particular condition is met, we run one block of code, and if not then we run another block.

28 mins

Exceptions

Exceptions happens! When exceptions happen, how should interpret the traceback for an exception? And how, when, and where should you catch exceptions?

62 mins

Data Structures

These screencasts are all about Python's core structures: lists, tuples, sets, and dictionaries.

51 mins

Functions

Python, like many programming languages, has functions. A function is a block of code you can call to run that code.

Python's functions have a lot of "wait I didn't know that" features. Functions can define default argument values, functions can be called with keyword arguments, and functions can be written to accept any number of arguments.

54 mins

Files

Reading from and writing to text files (and sometimes binary files) is an important skill for most Python programmers.

54 mins

Strings

Regardless of what you're doing in Python, you almost certainly use strings all the time. A string is usually the default tool we reach for when we don't have a more specific way to represent our data.

65 mins

Uncategorized Screencasts

These screencasts aren't included in any screencast series yet.

Watch a new Python screencast every week

Profile picture of Trey

My name is Trey Hunner. I do corporate Python training for teams and I teach Python online through Python Morsels.

In Python Morsels, I publish a new Python screencast every week.

If you want to learn something new every week, join Python Morsels!

Join Python Morsels ✨