Blog

  • One-day birthday sale — on July 14th, get 47% off my courses, books, and subscriptions

    Today is my birthday! To celebrate, I’m offering a one-day 47% sale on many of my products: My upcoming live classes (on functional Python, advanced Python objects, and decorators) are all 47% off Practice Makes Python (developer package), with 50 exercises to help you improve your Python, is 47% off Practice Makes Regexp (consultant package),…

    Read more

  • Announcing: Three live Python courses

    If you’re like many of the Python developers I know, the basics are easy for you: Strings, lists, tuples, dictionaries, functions, and even objects roll off of your fingers and onto your keyboard. Your day-to-day tasks have become significantly easier as a result of Python, and you’re comfortable using it for tasks at work and…

    Read more

  • Raw strings to the rescue!

    Whenever I teach Python courses, most of my students are using Windows. And thus, when it comes time to do an exercise, I inevitably end up with someone who does the following: for one_line in open(‘c:\abc\def\ghi’): print(one_line) The above code looks like it should work. But it almost certainly doesn’t. Why? Because backslashes (\) in…

    Read more

  • Announcing: Weekly Python Exercise

    I have a great job.  Really, I’m quite fortunate: For many years, I’ve spent nearly every day helping engineers at some of the world’s largest and best companies (including Apple, Cisco, Ericsson, HP, PayPal, SanDisk, and VMWare) to become better Python developers. My students are are experienced, intelligent engineers who are using Python in their…

    Read more

  • Boolean indexing in NumPy and Pandas: A free e-mail course for aspiring data scientists

    For nearly two years, I have been teaching my introductory course in data science and machine learning to companies around the world. On the one hand, participants are excited by data science, and all of the potential that it has to change our world. On the other hand, there is a lot to learn in…

    Read more

  • 2+2 might be 4, but what is True+True?

    In Python, we know that we can add two integers together: >>> 2 + 2 4 And of course, we can add two strings together: >>> ‘a’ + ‘b’ ‘ab’ We can even add two lists together: >>> [1,2,3] + [4,5,6] [1, 2, 3, 4, 5, 6] But what happens when you add two booleans…

    Read more

  • Python function brain transplants

    What happens when we define a function in Python? The “def” keyword does two things: It creates a function object, and then assigns a variable (our function name) to that function object.  So when I say: def foo():      return “I’m foo!” Python creates a new function object.  Inside of that object, we can see…

    Read more

  • The five-minute guide to setting up a Jupyter notebook server

    Bottom line: To run a Jupyter notebook server your students can log into, install it with pip3 install -U jupyter on a cheap Linux VPS, run jupyter notebook –generate-config, then set open_browser = False and ip = ‘0.0.0.0’ in jupyter_notebook_config.py. Launch it with nohup jupyter notebook and browse to port 8888. Nearly every day, I…

    Read more

  • A short Python class puzzle

    Here’s a short Python puzzle that I use in many of my on-site courses, which I have found to be useful and instructive: Given the following short snippet of Python, which letters will be printed, and in which order? print(“A”) class Person(object):     print(“B”)     def __init__(self, name):         print(“C”)         self.name = name    …

    Read more

  • Data science + machine learning + Python course in Shanghai

    Data science is changing our lives in dramatic ways, and just about every company out there wants to take advantage of the insights that we can gain from analyzing our data — and then making predictions based on that analysis. Python is a leading language (and some would say the leading language) for data scientists.…

    Read more