BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage Articles Author Q&A with Brett Slatkin on Effective Python

Author Q&A with Brett Slatkin on Effective Python

Bookmarks

InfoQ was able to talk with Brett Slatkin about his recently released book, Effective Python, and the newly available Effective Python LiveLessons.  These are video-based tutorials that cover 6 different areas and can be used with or without the book.  

  • Lesson 1: Using Expressions and Statements:  In the first lesson, you learn how to write programs in the Pythonic style, using methods that will affect every program you write.
  • Lesson 2: Using Comprehensions and Generators:  In Lesson 2, you learn how to use comprehensions and generators to work with and create sequences of values.
  • Lesson 3: Using Functions:  Lesson 3 covers a wide variety of unique capabilities that Python has for writing and calling functions.
  • Lesson 4: Using Classes: The focus of Lesson 4 is how to put Python's object-oriented capabilities to good use while at the same time avoiding common pitfalls.
  • Lesson 5: Working with Concurrency and Parallelism: Lesson 5 provides you with insights into Python's built-in facilities for writing programs that do many things at the same time.
  • Lesson 6: Making Programs Robust: In the final lesson, you learn the best techniques for making sure your programs are bulletproof when they run in production.

InfoQ: How should beginners approach the book?

Brett Slatkin: The best way to read the book is to look through the table of contents and see what catches your eye. The items are organized in groups, but there's no specific order in which you need to read them. You can jump around based on what you find interesting. That's the best way to read the book.   I've heard from a few people that they enjoyed starting with a subject they thought they already knew. I've heard from advanced programmers that my advice reaffirmed their instincts, which is great. From more intermediate programmers, I've heard that my advice made them realize they've always been doing it wrong. Luckily, both of those outcomes makes the reader more interested in the book's other items!   The other thing to note is that it is important to read items all the way through. Deep understanding of Python is hard to convey in a single sentence. Many of the items provide motivating examples that explain why the advice I give is relevant. Don't stop reading before you get to the good part!

  InfoQ: When do you think they should start to integrate the tips?

Brett: Immediately! Each item is ready to use as soon as you read it. If there's ever more to know from another item in the book, I explicitly reference it as a suggestion for additional study. The items are self-contained otherwise. There's no need to finish the whole book before you can start being a better Python programmer.

InfoQ: How should experienced Python programmers approach the book?

Brett: I'd say that advanced programmers should read the book with both skepticism and an open mind. Most of what I wrote should be obvious to an advanced Python programmer. Very little of what I wrote should be controversial. I built on the best practices I learned from my 10 years of professional Python programming. I had the wonderful opportunity to work with excellent Python programmers during that time. If you find yourself strongly disagreeing with me, perhaps you need to reexamine your Python style. Or maybe you've found an error! Please file those here (and thanks in advance for reporting it).

InfoQ: What are your thoughts about Python versus some of the other popular languages?  Does your answer change if you are talking with someone who is going to be a programmer versus a non-programmer who needs to learn programming for their "day job"?

Brett: Python's a remarkable language because it can be used by people who are learning how to program for the first time, as well as scientists programming a supercomputer (and much more). Python's scope is wide ranging and it's community members are multidisciplinary; that kind of diversity is an enormous strength that other languages can't match. If you start with Python you can go very far without ever having to use another language.   That said, I think you should always use the best tool for the job. For systems programming these days I'm very excited about Go. I still use Java and C++ at work all the time because they're good for specific problem domains. Swift is a must for iOS development; C# is necessary for game development; and you can't build web apps without knowing JavaScript. And of course, functional languages (like Lisp and OCaml) you should learn just to expand your mind.   I think all programmers should aspire to be polyglots, being proficient in many languages and switching between them as necessary. You never know what skill you'll need to use next.

InfoQ: Where should those new to Python start?  2.X or 3.X?

Brett: Now that NumPy, SciPy, Django, and many other community packages support Python 3, I'd recommend beginners start with Python 3 instead of Python 2. Many of the rough edges have been smoothed out in version 3, which should make it easier for newbies to understand. It is also better to start with Python 3 as a model of "doing it right". This encourages new programmers who still need to use Python 2 (e.g., for work) to try to apply the best practices of Python 3 in the environment of Python 2. That's generally the approach I took in my book. The items provide advice for the largest overlap of Python 2 and 3. I make it clear when techniques only work in Python 3. I provide alternatives for expressing the same ideas in Python 2.

  Thanks again to Brett for his time and participation.

About the Interviewee

Brett Slatkin is a Senior Staff Software Engineer at Google. He is the engineering lead and co-founder of Google Consumer Surveys. He formerly worked on Google App Engine’s Python infrastructure. He is the co-creator of the PubSubHubbub protocol. Nine years ago he cut his teeth using Python to manage Google’s enormous fleet of servers.

Rate this Article

Adoption
Style

BT