Hi, I'm Harlin and welcome to my blog. I write about Python, Alfresco and other cheesy comestibles.

Python - How to Use Underscores in Your Code

Note: This post was derived from Dan Bader's post on underscores that explains the subject in a lot more detail. If you are interested in reading his article, go here.

If you're a new Python programmer, you are likely encouraged to have a look at other programmer's ...

Read More

Python - Comprehending List Comprehensions

List comprehensions have been in Python since 2.6.x. If you're not using list comprehensions with Python, you are likely using a for statement and iterating through an iterable like this:

trees = 'oak', 'pecan', 'hickory', 'cherry'

for tree in trees:



You ...

Read More

Python - PEP 8 Series - Whitespace

Python is one of the few languages out there which takes whitespace into consideration for the purpose of readabilty. This is why this code is more elegant and flowable as you type:

def add_and_double(num1, num2):
    addition = num1 + num2
    product = addition * 2
    return product


public int (int num1, int ...

Read More

Python - How to Group Imports

In case you were ever wondering, here is the standard way to group your imports.

# Standard library imports
import os
import sys

# 3rd party modules
from django.http import HttpResponseRedirect
from django.shortcuts import render

# My project-wide modules
from blog.settings import THEME
from lib.util import get_http_referer

# From separate ...

Read More

Python - PEP 8 Series - Indentation

Consistent indentation of code is key for Python as you can get some painful indentation errors. If you really want to avoid that problem all together, always use 4 spaces for indentation. Also, avoid tabs, you don't need them.

Keep your lines at 79 characters or less. Continue to ...

Read More