Python Tricks: The Book

What Pythonistas Say About Python Tricks: The Book: ”I love love love the book. 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 emails as well, which is how I found out about the book.”

Python Tricks: The Book
Python Tricks: The Book

Table of contents :

  • Contents
  • Foreword
  • Introduction
  • What’s a Python Trick?
  • What This Book Will Do for You
  • How to Read This Book
  • Patterns for Cleaner Python
  • Covering Your A** With Assertions
  • Complacent Comma Placement
  • Context Managers and the Statement
  • Underscores, Dundas, and More
  • A Shocking Truth About String Formatting
  • The Zen of Python Easter Egg
  • Effective Functions
  • Python’s Functions Are First-Class
  • Lambdas Are Single-Expression Functions
  • The Power of Decorators
  • Fun With *args and **kwargs
  • Function Argument Unpacking
  • Nothing to Return Here
  • Classes & OOP
  • Object Comparisons: is vs ==
  • String Conversion (Every Class Needs a __repr__)
  • Defining Your Own Exception Classes
  • Cloning Objects for Fun and Profit
  • Abstract Base Classes Keep Inheritance in Check
  • What Namedtuples Are Good For
  • Class vs Instance Variable Pitfalls
  • Instance, Class, and Static Methods Demystified
  • Common Data Structures in Python
  • Dictionaries, Maps, and Hashtables
  • Array Data Structures
  • Records, Structs, and Data Transfer Objects
  • Sets and Multisets
  • Stacks (LIFOs)
  • Queues (FIFOs)
  • Priority Queues
  • Looping & Iteration
  • Writing Pythonic Loops
  • Comprehending Comprehensions
  • List Slicing Tricks and the Sushi Operator
  • Beautiful Iterators
  • Generators Are Simplified Iterators
  • Generator Expressions
  • Iterator Chains
  • Dictionary Tricks
  • Dictionary Default Values
  • Sorting Dictionaries for Fun and Profit
  • Emulating Switch/Case Statements With Dicts
  • The Craziest Dict Expression in the West
  • So Many Ways to Merge Dictionaries
  • Dictionary Pretty-Printing
  • Pythonic Productivity Techniques
  • Exploring Python Modules and Objects
  • Isolating Project Dependencies With Virtualenv
  • Peeking Behind the Bytecode Curtain
  • Closing Thoughts
  • Free Weekly Tips for Python Developers
  • PythonistaCafe: A Community for Python Developers

1 thought on “Python Tricks: The Book”

Leave a Comment