Everything You Need to Know About Python* You Learned from Harry Potter

There’s a great little cartoon which shows Harry Potter wielding his wand against a large snake and hurling a spell. One friend says “I didn’t know Harry spoke Python*,” because of course the spell is a bit of Python code, and the other friend says. “Yeah, he’s a parser-tongue.”  

He has a unique ability to communicate with snakes (which I believe is called “parseltongue”), and the name of Python is more closely related to Monty than Burmese. But let’s go with it anyway:

  • All proper languages have a strict legal definition, but they all have a set of idioms: common catch phrases or usages which are generally known and used. Python is the same way. It’s quite common for experienced programmers to write a bit of idiomatic code to do something they come across. Much like the spells that Harry and his wizard friends cast. Novices don’t seem quite as successful in casting spells as more experienced wizards, and I have often seen idiomatic code which doesn’t quite work very well from novice coders.
  • Harry doesn’t complete his formal schooling at Hogwarts School of Witchcraft and Wizardry because he is too busy fighting the dark and evil forces in the magical world. Casting spells, in other words. Here is something I have seen far too often – college students who drop out because they are having far too much fun programming. One of the most capable Python programmers I know is a fellow of the Linux Foundation but he got his degree in Physics rather than computer science.
  • Evidently in the Harry Potter universe, there is a vast underground bureaucracy in the British government dedicated to magic and magicians. This agency ensures that rules and laws are maintained so that utter chaos does not explode in the non-magic world. It’s as if there is a hidden infrastructure running all manner of stuff in the world, a conspiracy-theorist’s dream. Much like how Python underlies the majority of cloud computing – Software Defined Infrastructure (SDI) as it’s called. Nearly all is written in Python and if it were not there, the very fabric of our computing universe would become chaos, whether it’s the mechanisms running Amazon’s business or the OpenStack cloud infrastructure.
  • Harry and his friends sacrifice much to save the world from evil forces bent on death. One of the best uses of Python I have seen is when people use it to create good in the world and fight darkness. For example, Django Girls is a non-profit founded in July 2014 to “inspire women to fall in love with programming.” In such a brief time they have organized workshops all over the world with thousands of attendees, giving them amazing first experiences with technology. So many women are treated very badly in the male-dominated world of tech. Django Girls was started from the vision of its founders and has exploded worldwide into a movement which has fun and creates a safe place for programming. Many thanks to Ola and Ola for founding Django Girls and inspiring many to use their Python skills for good!

What kind of good can you do with Python? 

For more complete information about compiler optimizations, see our Optimization Notice.