Installation: For PHP programmers

  1. Tutorial files
  2. Installation
  3. Requirements

Most of the common programming languages today resemble C. Braces are used to mark off blocks of code, such as for functions, loops, and conditional code. And semicolons are used to mark the end of a piece of code. That style of coding gives you a lot of flexibility in how you format your code, but over time standards have emerged; one of those standards is indentation, another is one one line per statement.

Django uses Python as its programming language. Python doesn’t use braces or semicolons. Python was designed with the idea that since you’re going to indent anyway, the braces are redundant. So a function that looks like this in PHP:

function englishJoin(myList) {

lastItem = array_pop(myList);

commaList = implode(', ', myList);

if (count(myList) > 1) {

theAnd = ', and ';

} else {

theAnd = ' and ';


englishList = commaList . theAnd . lastItem;

return englishList;


might look like this in Python:

def englishJoin(myList):

lastItem = myList.pop()

commaList = ', '.join(myList)

if len(myList) > 1:

theAnd = ', and '


theAnd = ' and '

englishList = commaList + theAnd + lastItem;

return englishList

Where PHP uses “function”, Python uses “def”. You’ll also notice lots of periods. Python uses classes a lot; just about everything is a class in Python. The period is the equivalent of PHP’s -> symbol for accessing properties and methods. So, .pop() is a method on lists, and .join() is a method on strings.

The latter one is a little weird: you don’t tell give a string a concatenator and tell it to pull itself together; you give a concatenator a string and tell it to get to work.

Classes in Python are similar to classes in PHP. Instead of “class ClassName { … }”, you use “class ClassName(object):”, which is the equivalent of PHP’s “class ClassName extends OtherClassName { … }”. In Python, all or almost all of the classes you create will extend another class, even if that class is just the basic “object”.

  1. Tutorial files
  2. Installation
  3. Requirements