From the course: Python: Programming Efficiently
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Write Pythonic code - Python Tutorial
From the course: Python: Programming Efficiently
Write Pythonic code
- [Instructor] Idiomatic Python code, often called Pythonic, is code that embodies the design principles of the language. It's code that is true to Python's spirit. Furthermore, the Pythonic solution to a programming problem is usually the most efficient and most readable way to solve it. With this in mind, let us see how we can refactor a few snippets of code to make them more Pythonic. We use iterators and comprehensions and a few more idioms, including F strings, generic function arguments, and the built-ins all and any. I start by importing all the packages that we need. And here's some data that we need from the previous videos. The principles of Pythonic programming are described by an Easter egg within the language itself. It's the Zen of Python, which we get my running import this. It's worth thinking about all of these but my favorites are beautiful is better than ugly, simple is better than…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Writing Python efficiently50s
-
(Locked)
Python vs. C4m 40s
-
(Locked)
Design efficient loops7m 3s
-
(Locked)
Comprehensions and generators6m 41s
-
(Locked)
Exploit Python collections7m 14s
-
(Locked)
Write Pythonic code6m 44s
-
(Locked)
Challenge: Analyze Olympic medalist data1m 20s
-
(Locked)
Solution: Analyze Olympic medalist data1m 33s
-
(Locked)
-
-
-
-