• Document: Python Tricks: The Book. Dan Bader
  • Size: 232.55 KB
  • Uploaded: 2018-12-08 10:46:08
  • Status: Successfully converted

Some snippets from your converted document:

Python Tricks: The Book Dan Bader Copyright © Dan Bader (dbader.org), 2016 Cover design by Anja Pircher Design (anjapircher.com) Thank you for downloading this ebook. This ebook is licensed for your personal enjoyment only. This ebook may not be re-sold or given away to other people. If you would like to share this book with an- other person, please purchase an additional copy for each recipient. If you’re reading this book and did not purchase it, or it was not pur- chased for your use only, then please return to dbader.org/pytricks- book and purchase your own copy. Thank you for respecting the hard work behind this book. If you’d like to let me know about an error, or if you just have a question, or want to offer some constructive feedback, email me at mail@dbader.org. This is a sample from “Python Tricks: The Book” The full version of the book includes many more Python Tricks that will teach you the depths and quirks of Python with fun and easy to understand examples and explanations. If you enjoyed the sample chapter you can purchase a full version of the book at dbader.org/pytricks-book. Contents Contents 4 1 Introduction 5 1.1 What’s a Python Trick? . . . . . . . . . . . . . . . . 5 1.2 What This Book Will Do for You . . . . . . . . . . . 7 1.3 How to Read This Book . . . . . . . . . . . . . . . . 8 2 Sample Chapters 9 2.1 “is” vs “==” . . . . . . . . . . . . . . . . . . . . . . 10 2.2 Complacent Comma Placement . . . . . . . . . . . . 13 4 Chapter 1 Introduction 1.1 What’s a Python Trick? Python Trick: A short Python code snippet meant as a teaching tool. A Python Trick either teaches an aspect of Python with a simple illustration, or serves as a mo- tivating example to dig deeper and develop an intuitive understanding. Python Tricks started out as a short series of code screenshots that I shared on Twitter for a week. To my surprise, they got a raving response and were shared and retweeted for days on end. More and more developers started asking me for a way to “get the whole series”. I only had a few of these tricks lined up, spanning a variety of Python-related topics. There wasn’t a master plan behind them. Just a fun little Twitter experiment. But from these inquiries I got the sense that these short-and-sweet code examples would be worth exploring as a teaching tool. Eventu- ally I set out to create a few more Python Tricks and shared them in 5 CHAPTER 1. INTRODUCTION 6 an email series. Within a few days several hundred Python develop- ers had signed up and I was just blown away by that response. Over the next days and weeks, a steady stream of Python develop- ers reached out to me. They thanked me for making a part of the language they were struggling to understand click for them. Hear- ing this feedback felt awesome. These Python Tricks were just code screenshots, I thought. But some people were getting a lot of value out of them. Therefore I decided to double down on my Python Tricks experiment and expanded it into a series of around 30 emails. These were still just a headline and a code screenshot each, and I soon found the limits of that format. A blind Python developer emailed me, disap- pointed to find that these Python Tricks were delivered as images he couldn’t read with his screen reader. Clearly, I needed to invest more time into this project to make it more appealing and also more accessible. I sat down to re-create the whole series of Python Tricks emails with a plain text version and proper HTML-based syntax highlighting. That new iteration of Python Tricks chugged along nicely for a while. Based on the re- sponses I got, developers seemed happy they could finally copy and paste the code samples to play with them. As more and more developers signed up for the email series I started noticing a pattern in the replies and questions I received. Some Tricks worked well as motivating examples by themselves—but for the more complex ones there was no narrator to guide readers or to give them additional resources to develop a deeper understanding. Let’s just say this was another big area of improvement. My mission statement for dbader.org is to help Python developers become more awesome—and this was clearly an opportunity to get closer to that goal. CHAPTER 1. INTRODUCTION 7 I decided to take the best and most valuable Python Tricks from the email course and started writing a new kind of Python book around them: • A book that teaches the coolest aspects of the language with short and easy to digest examples. • A book that works like a buffet of awesome Python features (yum!) and keeps motivation high. • A book that takes you by the ha

Recently converted files (publicly available):