Category: Python

  • Playing with Python strings, lists, and variable names — or, a complex answer to a simple question

    I recently received a question from a reader of my “Better developers” list. He asks: Is there any way to turn a str type into a list type? For example, I have a list of elements, and want to turn that element into a separate list. For example, if I have test = [‘a’, ‘b’,…

    Read more

  • “Python Workout” is Manning’s Deal of the Day!

    I’m a firm believer in improving your Python fluency via practice, practice, and more practice. “Python Workout” is a collection of my 50 favorite exercises from my 20 years of on-site Python training at some of the world’s largest and best-known companies. I’m delighted to announce that “Python Workout,” my book with 50 exercises to…

    Read more

  • Variables are pronouns: A simple metaphor for Python newbies

    I teach about 10 different courses to companies around the world, but my favorite remains “Python for non-programmers.” Participants in this course are typically network and system administrators, support engineers, and managers who want to learn some programming skills, but don’t see themselves as programmers. Moreover, many of them took a programming course back when…

    Read more

  • Sharpen your Python skills with Weekly Python Exercise

    It’s time for another cohort of Weekly Python Exercise! This time, it’s an advanced cohort with 15 weeks of practice in such subjects as functional programming, object-oriented programming, iterators, generators, and decorators. Early-bird pricing ends in just one week, on June 18th! Learn more, and get a sample, at https://WeeklyPythonExercise.com/.

    Read more

  • Why do Python lists let you += a tuple, when you can’t + a tuple?

    Let’s say you have a list in Python: >>> mylist = [10, 20, 30] You want to add something to that list. The most standard way to do this is with the “append” method, which adds its argument to the end of the list: >>> mylist.append(40) >>> print(mylist) [10, 20, 30, 40] But what if…

    Read more

  • Registration (and early-bird pricing) is open for Weekly Python Exercise

    Do you use Python, but sometimes feel stuck? Do you visit Stack Overflow every time you want to solve a problem? Do you wish that you understood how to use advanced techniques, such as generators and decorators, better? If so, then good news: I’m opening a new cohort of Weekly Python Exercise, specifically aimed at…

    Read more

  • Python dicts and memory usage

    Bottom line: Use sys.getsizeof to measure a dict’s memory: an empty dictionary takes 240 bytes, because it starts with eight slots ready for key-value pairs. That number reflects the structure, not the data, so it stays at 240 no matter how big your values are, growing in jumps only as you add more pairs. Let’s…

    Read more

  • Weekly Python Exercise A2 (functions + modules for beginners) closes today

    If you are a relative beginner to Python, and want to improve your understanding of functions and modules, then there’s no better way to do so than practice. Weekly Python Exercise provides you with that practice, with a family of six 15-week courses. In each course, you get a question on Tuesday, the answer on…

    Read more

  • “Python Workout” is Manning’s Deal of the Day!

    If you’ve just finished a Python course or book, then you might feel a bit nervous about your Python knowledge. You might be wondering how you can become a master Python developer, solving problems without turning to Stack Overflow every few minutes. The good news is that you can improve! But getting better at Python…

    Read more

  • My interview on the “Talk Python” podcast

    I was delighted to appear on the popular “Talk Python to Me” podcast, run by Michael Kennedy. In the podcast, I talk about teaching, learning, and teaching Python to companies. If you’re interested in how to learn better or teach better, then I think you’ll enjoy this episode! The episode is here: https://talkpython.fm/episodes/show/210/making-the-most-out-of-in-person-training

    Read more