Category: Python

  • Making Python’s __init__ method magical

    In some programming languages, the idea of “reflection” is somewhat exotic, and takes a while to learn. In Python (and Ruby, for that matter), the language is both dynamic and open, allowing you to poke around in the internals of just about any object you might like.  Reflection is a natural part of working with…

    Read more

  • Python scoping e-mail course

    I had so much fun writing the previous blog post about Python scoping that I decided to expand it into a free e-mail course.  Each day (for five days), you’ll receive another lesson about how scopes work in Python, and why this is important for you to know as a Python developer. So if you’ve…

    Read more

  • Fun with Python scoping rules

    Let’s say I want to try something on a list in Python.  While I usually like to call my test list objects “mylist”, I sometimes forget, and create a variable named “list”: list = [‘a’, ‘b’, ‘c’] If you’re like me, then you might not immediately notice that you’ve just defined a variable whose name…

    Read more