Yesterday I discovered a project under MediaWiki written in Python. The project is EventLogging that captures data about users as they interact with MediaWiki sites. On viewing the code, I noticed a couple of inconsistencies and out of curiousity asked where the MediaWiki code guidelines were for Python. They didn’t exist but for a single line in the MW:Code Conventions that mentions the PEP8 whitespace guidelines.

The folks in #mediawiki-e3 recommended that I be WP:BOLD and write some guidelines, so I did. The guidelines are PEP8, but in the article I pulled out a few of the more important points and added pieces of PEP257 to make a more clear docstring standard.

I did learn from the discussion about standards that quite literally everyone has an opinion about how docstrings should be formatted, and was reminded that we no longer code on VT100 terminals, making a line width of 79 less a requirement and more of a “would be nice”.

I was surprised an organization as large as MediaWiki wouldn’t have code guidelines for Python, especially since it has such comprehensive ones for PHP, JavaScript, and even CSS. I’m especially glad the community was so welcoming and let me contribute to something so core to the community.