What the hell? Openshift!!

Neglecting all I’ve been taught on TDD, I set out to do a demo app. Why, yes, I decided to host on a Paas, afterall, this kid is excited about it.


Don’t tell me heroku, that’s so cliche, although if it makes you feel better, I also hosted same app on heroku.

That said, openshift seemed a good bet. It offers persistent file uploads (not forcing me to use AWS S3) at a convenience, plus 1GB storage space, and lots more. Sadly, the documentation is poor – compared with heroku, for example. For a while, I was like:


I didn’t give up though. Errors upon errors, issues upon issues, just to deploy a simple demo app. Where’s the love, paas??

Screen Shot 2015-06-01 at 21.14.57
Thankfully, the good guys at StackOverflow gave me tips in-between.

Long story short, and to stop annoying you with these memes, I got it running! To save myself (and others, hopefully) this same trouble, I will be writing a tutorial on openshift in my category. No doubt, the app we’ll be hosting is a Python app. In the meantime, this is how I’m handling openshift deployments, until I get the hang of it:

For the record, next time, I’ll try to mimimize my problems using:

Images courtesy of Google


Variables in Python

This is the second of a series of Python lessons. The aim of this series is to help provide an avenue for me to record what I know so far about this amazing language.

So what is a variable in Python?

A variable is simply a location in memory.

For people coming from other languages, you might think this simple definition holds true enough in Python. However, in Python, a variable is a pointer to an object (and it’s memory location). Remember that in this language, everything is an object. A string, a number, an expression, a function, another string, another number, and another string again – all unique objects! Understanding this concept is the foundation to understanding Python and it’s OOP model. Let’s examine the code below:

string = "this is a string"

Looking at this, one might think that the string above refers to a location in memory. If that’s the reasoning, then this code below:

string = "this has been edited"

would mean that the string would refer to the same memory location, only this time, it has been reassigned and thus has a different value. This is not the case in Python. Let’s use the built-in id method to verify this.

The id function in Python returns the identity – the memory address – of an object. Loosely, it refers to the location in memory of the said object. Let’s try this:

In [1]:
string = "this is a string"
In [2]:
string = "string edited"
 I am using the amazing iPython Notebook. You should try it out. I digress.
So, from the demo above, we see that even though the variable string is one and same variable, the id changes when it’s value changes. This is exactly the binding model of Python. It means that python binds variable names to objects, in this case “this is a string”, or “string edited”. Because both values are different, they are two different objects, with different memory locations, even though they are bound to same variable string. What happens is that when the string was reassigned, Python removed the binding of string from “this is a string” to “string edited”, meaning the first (“this is a string”) can exist unbound on it’s own.
To summarize, python binds variable names to objects. It is these bound objects that have a location in memory, not the variable names; the variable names merely point to the particular bound objects.


I’m really excited about this. I’ve recently started learning Python, and I gotta say that I’m hugely impressed with the language. From it’s expressiveness to it’s myriad of packages, this is one tool that can get your job done in no time.




I’ll try to be releasing about two to three articles weekly. I feel the best way to learn something is to practice….and teach it. I’m practicing using the rubber duck approach of learning.

I hope you’ll find this useful. You can filter all my python articles with the tag ‘python’.

In the meantime, I’m building my personal blog using Flask, a Python web microframework.