Write Pythonic Code Like a Seasoned Developer Course

Course Summary

This course will take you on a tour of over 50 of the more popular and useful code examples demonstrating Pythonic code. In the examples, you'll first see non-Pythonic code and then the more natural Pythonic version.

One of the special concepts in Python is the idea of writing idiomatic code that is most aligned with the language features and ideals. In Python, we call this idiomatic code Pythonic. While this idea is easy to understand, it turns out to be fairly hard to make concrete.

Topics covered include the expansive use of dictionaries, hacking Python's memory usage via slots, using generators, comprehensions, and generator expressions, creating subsets of collections via slices (all the way to the database) and many more. Several of these are Python 3 features so you'll have even more reason to adopt Python 3 for your next project.

What students are saying

I have decided to get hands on again and learn a new language, python! I have been working through your courses, Python Jumpstart, Pythonic code and Python for Entrepreneurs in parallel. They are amazing and your teaching is fantastic.
-- Andre O.

Source code and course GitHub repository

github.com/mikeckennedy/write-pythonic-code-demos

What is Pythonic code and why does it matter?

One of the special concepts in Python is the idea of writing idiomatic code that is most aligned with the language features and ideals. In Python, we call this idiomatic code Pythonic. When you write Pythonic code, you are leveraging over 25 years of experience of many thousands of developers. You are writing code that is expected and tune in the CPython runtime. Most importantly perhaps, you are writing code that is easily read and understood by your fellow and senior Python developers.

If you are building an open source product, it will be easier for other contributors to join in if your code is Pythonic. If you are running a software team, it will be easier to on-board Python developers new to your company.

On the flip side, if you are somewhat new to Python, you may be broadcasting this loud and clear to everyone listening: your teammates, interviewers if you're looking for a new job, audience members if you're giving a public presentation. This is less than ideal.

Finally, many of the over 50 tips covered in this course that are considered "Pythonic" allow you to write more readable code, more maintainable code, and more efficient code. So in some sense, you can think of this course as an effective Python course in its own right.

Who is this course for?

The course is for beginner to intermediate Python developers looking to hone their Python programming skills and become true professionals in the Python space. It is not a "Learn Python from Scratch" course and assumes you are familiar with language constructs such as modules, functions, classes, and more.

If you are looking to learn Python from scratch, please consider my Python Jumpstart by Building 10 Apps course.

Write code like professional Python developers

Even if you are an experienced developer in another language, your skills may not translate directly to Python in an idiomatic way. If you take code or an algorithm from another language, say Java, and convert it to Python and get it running, chances are this code is a little off. People reading your code will know it's "foreign".

This course will inculturate you into the Python community. You will learn to write code that is most natural to Python's language features and capabilities.

What topics will we cover?

This course covers over 50 concrete programming tips to write more Pythonic code. These tips are grouped into the following broad categories.

  1. Pythonic Foundational Concepts
  2. Dictionaries
  3. Generators and Collections
  4. Methods and Functions
  5. Modules and Packages
  6. Classes and Objects
  7. Loops
  8. Tuples
  9. Python for Humans

See the full course table of contents below.

Concepts backed by concise visuals

This course will focus extensively on showing you the concepts organically through live demos editors, executing code, and more. But each topic has one or two concept graphics that freeze the idea to highlight the core concepts.

Here is an example for the section that shows you that dictionaries can be leveraged to add the concept of a switch statement to the Python language.

Example: Concepts backed by concise visuals

Follow along with subtitles and transcripts

Each course comes with subtitles and full transcripts. The transcripts are available as a separate searchable page for each lecture. They also are available in course-wide search results to help you find just the right lecture.

Each course has subtitles available in the video player.

Who am I? Why should you take my course?

Who is Michael Kennedy?

My name is Michael, nice to meet you. ;) There are a couple of reasons I'm especially qualified to teach you Python.

 1. I'm the host of the #1 podcast on Python called Talk Python To Me. Over there, I've interviewed many of the leaders and creators in the Python community. I bring that perspective to all the courses I create.

 2. I've been a professional software trainer for over 10 years. I have taught literally thousands of professional developers in hundreds of courses throughout the world.

 3. Students have loved my courses. Here are just a few quotes from past students of mine.

"Michael is super knowledgeable, loves his craft, and he conveys it all well. I would highly recommend his training class anytime." - Robert F.
"Michael is simply an outstanding instructor." - Kevin R.
"Michael was an encyclopedia for the deep inner workings of Python. Very impressive." - Neal L.

Free office hours keep you from getting stuck

One of the challenges of self-paced online learning is getting stuck. It can be hard to get the help you need to get unstuck.

That's why at Talk Python Training, we offer live, online office hours. You drop in and join a group of fellow students to chat about your course progress and see solutions via screen sharing.

Just visit your account page to see the upcoming office hour schedule.

Is this course based on Python 3 or Python 2?

This course is based upon Python 3. Python 2 is officially unsupported as of January 1st, 2020 and we believe that it would be ill-advised to teach or learn Python 2. This course is, and has always been, built around Python 3.

The time to act is now

Become the Python developer you have always wanted to be. Join this course right now.

Course Outline: Chapters and Lectures

Welcome to the course
14:09
Welcome and thanks for coming
4:27
Topics covered
3:56
Get the source code
0:19
Do you need to learn Python too?
0:18
Python 3 or Python 2?
1:59
Recommended editor
1:05
Video player: A quick feature tour
2:05
Style guidance from PEP 8
13:52
Who decides what is Pythonic?
1:54
Import statements
3:59
Code layout and structure
2:47
Documentation strings
2:08
Naming conventions
3:04
Foundational Concepts
32:10
Truthiness and boolean statements
5:57
Testing for None
2:23
Multiple tests against a single variable
6:18
Choosing an item at random
3:32
String formatting
7:07
Care enough to send an exit code
2:49
Flat is better than nested
4:04
Dictionaries
44:01
Why dictionaries
1:43
Stop using lists for everything
9:33
Merging dictionaries
6:15
Hacking Python's memory
9:03
Safer dictionary item access
7:38
Dictionaries as switch statements
6:26
To and from JSON
3:23
Generators and Collections
37:20
Custom iteration and your types
4:13
Testing for containment
3:21
Slicing collections all the way to the database
7:22
On-demand computation with yield and generators
8:09
Recursive generators with yield from
3:41
Inline generators via expressions
6:22
Counting generators
4:12
Methods and Functions
35:45
Introduction to Pythonic functions
1:18
Leverage inline methods with lambda expressions
7:05
I'm going to ignore your return value
7:29
There is no method overloading in Python
2:42
Default values for overloads
3:39
Variable argument counts for overloads
2:21
Unpacking dictionaries as named arguments
3:42
Beware: The danger of mutable default arguments
7:29
Modules and Packages
19:14
Introduction to packaging and module idioms
1:48
Pythonic import statements
5:53
What is __main__ and when do you use it?
5:21
Isolation with virtual environments
2:33
State your requirements
3:39
Classes and Objects
16:30
Defining fields on classes
6:18
Encapsulation and data hiding
5:27
Do not write get_thing() set_thing()
4:45
Pythonic Loops
8:50
There is no numerical for loop
2:27
Wait, is there a numerical for loop (v1)?
1:50
Wait, is there a numerical for loop (v2)?
1:47
Loops have an else block, don't use it
2:46
Tuples
13:32
Tuple assignment and unpacking
3:56
Swapping values
1:24
Multiple return values from a function
3:28
Prefer named tuples
4:44
Python for Humans
11:13
Human Python as a stand in for packages in general
3:14
Requests: HTTP for Humans
4:19
Records: SQL for Humans
3:40
Course Conclusion
7:55
You've done it!
0:24
Lightning review
6:06
Source code
0:32
Thanks and bye
0:53
Buy for $49 + tax Bundle and save 85% Team Gift

Questions? Send us an email: contact@talkpython.fm

Talk Python's Mastodon Michael Kennedy's Mastodon