The bool function in Python

Python’s built-in bool  function comes in pretty handy for checking the truth and falsity of different types of values. First, let’s take a look at how True and False are represented in the language. True and False are numeric values In Python intern ...

What to do after Codecademy

Today I want to offer my opinion on a question that lots of people have asked me since I started this blog. “What should I do after I have finished an introductory course on Codecademy?” Codecademy is basic stuff You should be proud to have finished you ...

Text to speech with Python 3 on Linux and OSX

Recently I had a requirement to synthesise speech from text on two different operating systems. Here is what I came  up with. OSX Synthesising speech is a simple matter for OSX users because the operating system comes with the say  command. We can use s ...

The difference between range and xrange in Python

Today I’m going to take a look at another difference between Python 2 and 3 that can trip up people making the switch. Python 2 used to have two functions that could be used to iterate a certain number of times in for  loops, range  and xrange . In Python ...

The difference between input and raw_input in Python

One of the first things that people notice when they ditch Python 2 and start coding in Python 3 – apart from the fact that print  is now a function – is that the raw_input  function has disappeared. So this Python 2 code: bottles = raw_input("Daily be ...

How to fix database race conditions in Django views

Today I’m going to show you how to fix an extremely common error in Django applications. My guess is about 90% of Django applications deployed in the wild suffer from this error, and like 72% of statistics I just made that one up on the spot. Seriously th ...