With Python Tricks: The Book you’ll discover Python’s best practices and the power of beautiful & Pythonic code…explained with simple examples and a step-by-step narrative.
You’ll get one step closer to mastering Python, so you can write beautiful and idiomatic code that comes to you naturally.
Learning the ins and outs of Python is difficult—and with this book you’ll be able to focus on the practical skills that really matter.
You’ll discover the “hidden gold” in Python’s standard library and start writing cleaner and more Pythonic code today.
If you’re wondering whether or not this book is right for you, here’s who can benefit the most from this material:
If you’re wondering which lesser known parts in Python you should know about, you’ll get a roadmap with this book. Discover some cool (yet practical!) Python tricks and get ready to blow your coworkers’ minds in your next code review.
If you’ve got experience with legacy versions of Python, the book will get you up to speed with modern patterns and features introduced in Python 3 and backported to Python 2.7. It’ll be a fun way to take advantage of recent improvements in the language, one bite at a time.
If you’ve worked with other programming languages and you want to get up to speed with Python, you’ll pick up the idioms and practical tips you need to become a confident and effective Pythonista.
If you want to make Python your own and learn how to write clean and Pythonic code, you’ll discover best practices and little-known tricks to round out your knowledge in the book. Get one step closer to Python mastery and fill up your toolbox. How awesome will it feel to look back at all the beautiful and well-engineered code you’re going to write?
The book package includes 12 HD-quality Python tutorial videos, adding up to over 127 minutes of run-length.
These videos go hand-in-hand with key chapters in the book to help you learn faster and retain your knowledge better. You’ll see step-by-step how to apply what you learned in the book in a real coding environment.
Dan Bader is the owner and editor in chief of Real Python and the main developer of the realpython.com learning platform. Dan has been writing code for more than 20 years and holds a master's degree in computer science.
The book contains 295 pages broken down into 9 chapters with 5-7 actionable Python tips per chapter. All of the material is completely up to date for Python 3.
Each page in the book has been carefully laid out with beautiful typography, syntax highlighting for code examples, and bulleted-list summaries are provided so you can process and memorize the information effectively:
Let’s have a look at the contents of the book. In a nutshell, here’s what you’ll learn with Python Tricks: A Buffet of Awesome Python Features:
Chapter 1: Introduction How to make the most of this book so you can learn effectively and apply your newfound knowledge in the real world.
Chapter 2: Patterns for Cleaner Python How to write clean and maintainable Python code using Python-specific patterns like Context Managers and making sense of Python’s underscore-based naming conventions.
Chapter 3: Effective Functions What makes Python functions “first-class citizens,” whether using lambda functions is a good idea or not, a deep-dive on Python decorators, what
**kwargs function parameters are good for, and more.
Chapter 4: Classes & OOP In this chapter you’ll get tips for effective object-oriented programming (OOP) with Python. Among other things you’ll learn how to define your own exception classes, why every class needs a
__repr__ method, and how abstract base classes (ABCs) can help you write more maintainable OOP code.
Chapter 5: Common Data Structures in Python In this part of the book you’ll take a tour of the fundamental data structures and implementations of abstract data types (ADTs) built into Python and its standard library. This information will also help you shine in Python coding interviews.
Chapter 6: Looping & Iteration Discover how to write Pythonic loops and learn how to leverage data processing constructs like comprehensions, generators, iterators, and iterator chains.
Chapter 7: Dictionary Tricks Get tips and tricks for working effectively with one of Python’s most-used data structures, the dictionary (
Chapter 8: Pythonic Productivity Techniques How to explore modules and objects interactively using the Python REPL, how you can isolate project dependencies with “virtual environments,” and a look at what’s happening “behind the scenes” in Python’s bytecode interpreter.
Chapter 9: Closing Thoughts How to use your newfound knowledge to write better, cleaner, and more efficient Python code.
If you’d like to take a closer look at the book contents and read a full table of contents, click here to download the sample chapters (PDF). Also, here’s a preview lesson from the bonus video course:
“You’ll be more confident when writing Python programs”
“By contributing to Python as a CPython core developer, I get connected to many members of the community. In my journey, I found mentors, allies, and made many new friends. They remind me that Python is not just about the code, Python is a community.
Mastering Python programming isn’t just about grasping the theoretical aspects of the language. It’s just as much about understanding and adopting the conventions and best practices used by its community.
Dan’s book will help you on this journey. I’m convinced that you’ll be more confident when writing Python programs after reading it.”
— Mariatta Wijaya, Python Core Developer
“I do get something out of every chapter”
“I first heard about your book from a co-worker who wanted to trick me with your example of how dictionaries are built. I was almost 100% sure about the reason why the end product was a much smaller/simpler dictionary but I must confess that I did not expect the outcome :)
He showed me the book via video conferencing and I sort of skimmed through it as he flipped the pages for me, and I was immediately curious to read more.
That same afternoon I purchased my own copy and proceeded to read your explanation for the way dictionaries are created in Python and later that day, as I met a different co-worker for coffee, I used the same trick on him :)
He then sprung a different question on the same principle, and because of the way you explained things in your book, I was able to **not** guess the result but correctly answer what the outcome would be.
That means that you did a great job at explaining things :)
I am not new in Python and some of the concepts in some of the chapters are not new to me, but I must say that I do get something out of every chapter so far, so kudos for writing a very nice book and for doing a fantastic job at explaining concepts behind the tricks!
I’m very much looking forward to the updates and I will certainly let my friends and co-workers know about your book.”
— Og Maciel, Python Developer at Red Hat
“This book makes you write better Python code!”
“I really enjoyed reading Dan’s book. He explains important Python aspects with clear examples (using two twin cats to explain “is” vs “==” for example).
It is not just code samples, it discusses relevant implementation details comprehensibly.
What really matters though is that this book makes you write better Python code!
The book is actually responsible for recent new good py habits I picked up, for example: using custom exceptions and ABC’s (I found Dan’s blog searching for abstract classes).
These new learnings alone are worth the price.”
— Bob Belderbos, Engineer at Oracle & Co-Founder of PyBites
“It’s like having a seasoned tutor explaining, well, tricks!”
“I love love love the book so far. It’s like having a seasoned tutor explaining, well, tricks!
I’m learning python on the job and I’m coming from powershell, which I learned on the job - so lots of new, great stuff. Whenever I get stuck in python (usually with flask blueprints or I feel like my code could be more pythonic) I post questions in our internal Python chat room.
I’m often amazed at some of the answers coworkers give me. Dict comprehensions, lambdas, and generators often pepper their feedback.
I am always impressed and yet flabbergasted at how powerful python is when you know these tricks and can implement them correctly.
Your book was exactly what I wanted to help get me from a bewildered powershell scripter to someone who knows how and when to use these pythonic ‘tricks’ everyone has been talking about.
As someone who doesn’t have my degree in CS it’s nice to have the text to explain things that others might have learned when they were classically educated.
I am really enjoying the book and am subscribed to the email as well, which is how I found out about the book.”
— Daniel Meyer, Sr. Desktop Administrator at Tesla Inc.
“Makes me re-think some of the assumptions I have about Python”
“I’ve been developing in Python for quite a few years now, and I’m discovering lots of interesting and useful information in your book.
I love idioms, particularly in Python with its ‘one obvious way to do something’ approach to programming.
Your in depth look at how things work is great because it makes me re-think some of the assumptions I have about Python, and either take precautions or advantage of what I just learned.”
— Doug Farrell, Senior Web Engineer at Shutterfly
To recap, let’s take another look at what you’ll receive with this offer:
DRM-free PDF book, optimized for reading on tablets and computers (295 pages)
DRM-free ePub book
DRM-free Kindle book
12 HD-quality Bonus Videos (2+ hours total)
What Readers Say…
“Perfection in clarity & relevancy in understanding the important fundamentals of the language. Truly well done.”
— Luie Matthee( Verified Review)
1 Year “Try It Yourself” Guarantee—
100% Money-Back Refund Policy
The last thing we want is for you to pass on this deal because you’re not sure it’ll work for you. We know it will, so here’s our offer to you:
Put us to the test. Take this book for a spin today.
Spend just a few days with the material and start building your Python skills.
Then take up to a full year to grow them…
And if for some reason you don’t agree that we’ve given you a faster, easier way to absorb the knowledge you need to rise head-and-shoulders above other developers, we’ll cheerfully refund your money, no questions and no hassles, any time within the next year.
Either way, all the risk is on us.
Frequently Asked Questions
This is a digital ebook that you can access at any time and read on your computer, tablet, and other eReader devices. Once your payment is submitted, you will get download access to the book files in your Real Python account.
Yes, your purchase includes full (human-made!) subtitles and searchable transcripts for all video lessons.
We want happy customers only. If you’re not happy with the digital version of the book, send us an email and tell us where it left you hanging. We’ll refund you in full—even 12 months later.
Yes, the payment provider we use (Paddle) supports PayPal, Apple Pay, and credit card payments. Just click the “Buy Now” button and then select the PayPal logo on the checkout page. Please note that PayPal checkout might not be available in all countries.
We announce updates via email as they come out. Plus, you’ll always find the latest version of the book available for download in your realpython.com account.
Please email us at email@example.com and we’ll get back to you as soon as possible.