Python Tutorials

  • By
    Checkout the Last Public Revision with Mercurial

    I've always preferred git over Mercurial (hg) because the feature branch workflow makes organizing code and working off of master very easy. You don't get that with vanilla mercurial -- instead, commits can just sort of apply on top of each other, without much organization.

  • By
    Change Python Version

    Python plays a major role at Mozilla; much of our website backends and tooling are written in the powerful language.  Want to build Firefox?  You'll need to make sure you have the proper Python version, which I recently found out had been upgraded. Despite installing and verifying...

  • By
    Get Python Requirements Package Hashes

    Python's (pip's) requirements.txt file is the equivalent to package.json in the JavaScript / Node.js world.  This requirements.txt file isn't as pretty as package.json but it not only defines a version but goes a step further, providing a sha hash to compare against to ensure package integrity: Coming from the JavaScript / package.json world, you only need...

  • By
    httpstat: Simple cURL Stats

    There are a lot of tools out there that do great, advanced things but present them as well as they could be presented.  I wont knock cURL for anything -- it's an amazing tool many of us can't live without;  what I will say, however, is that...

  • By
    Serve a Directory via Python

    Sometimes I'm working with a test HTML file and some JavaScript but need to work off of a served space.  In that case, I sometimes need to swap out folders within MAMP Stack which leads to a maintenance nightmare.  Bleh. I recently found out that you can...

  • By
    Python html5lib Skipped Elements

    I've been working on some interesting python stuff at Mozilla and one task recently called for called for rending a page and then finding elements with a URL attribute value (like img[src] or a[href]) and ensuring they become absolute URLs.  One problem I encountered when using...

  • By
    Get a Python Package Version

    Part of maintaining a Django-based application like MDN's kuma is ensuring Python packages are up to date.  I was recently testing an upgrade on a remote system and needed to ensure that a given Python package was at the version number it should be.

  • By
    Scraping iTunes Charts Using Scrapy Python

    Hacking is more fun when you have some data to play with, but from where do you get data when you are just hacking for fun? I use web scraping to make my hacks interesting and cool and have learned a lot in the process. In...

  • By
    Run Individual Cron Routines within Django

    When you're looking to run a single cron routine within Django, hit the terminal and run this: To see a list of available cron routines, run: Running individual cron routines is probably an obvious flow for Django experts but hopefully this is easier to find than searching through...

  • By
    An Introduction to Persona

    So you've heard of this new hipster login service called Persona. It promises to relieve you of dealing with passwords, and be easy to setup. Can it really? I'm here to walk you through setting up Persona on your own website, in just a...