Mozilla uses a lot of Python. Most of our build system, CI configuration, test harnesses, command
line tooling and countless other scripts, tools or Github projects are all handled by Python. In
mozilla-central there are over 3500 Python files (excluding third party files), comprising roughly
230k lines of code. Additionally there are 462 repositories labelled with Python in the Mozilla
org on Github (though many of these are not active). That’s a lot of Python, and most of it is
With Python 2’s exaugural year well underway, it is a good time to take stock of the situation and
ask some questions. How far along has Mozilla come in the Python 3 migration? Which large work items
lie on the critical path? And do we have a plan to get to a good state in time for Python 2’s EOL on
January 1st, 2020?
Read more →
That’s not a rhetorical question. I’d like to know in which scenarios a mixin in python really is
the best option. I can’t seem to think of any, but maybe I’m not thinking outside the box enough.
The basic idea of a mixin is to create a small re-usable class that can “plug-in” to other larger
classes. From the wikipedia definition, a mixin is a way to compose classes together without
using inheritance. The problem is unlike ruby, python mixins are a purely conceptual construct.
Python mixins are inheritance (the only difference is that the class name usually contains
‘Mixin’). It is up to the developer to remember this, and to manually avoid all of the common
pitfalls of multiple inheritance. This kind of defeats the whole purpose of the mixin in the first
place. What’s more is that most people use python mixins improperly.
Read more →
I came across an odd python problem the other day. I wanted to format a log message without printing
it with python’s logging module. But I couldn’t find any examples or others who wanted to do the
You might ask why I would want to do this. In my case, I was using sys.stdout.write() to display the
progress of a download as a percentage. Python’s logging module automatically appends a newline to
your message and there didn’t seem to be a way to change this without a subclass. Anytime you want
to overwrite something on the previous line with python logging, you will run into trouble.
Read more →