Python

Maintaining state while threading in Python

If you have ever worked with threading in Python before, you may have encountered issues where everything gets a little bit out of step (if you’re incrementing a counter, 2 threads may simultaneously try to increment it & mess up your program). So we can deal with that using queues. Let’s walk through an example […]

Read more
Python

A crash course in threading and multiprocessing in python

When you first start looking into asynchronous processing in Python, you’ll come across a couple of terms: threading and multiprocessing. The first part of this article then, is about understanding what those two terms mean and when you should use one over the other. What is threading? Threading is a way to overcome performance issues […]

Read more
Python

UPDATED: All about classes in python

Classes are great when you’re working with concepts in the real world. They are by no means a necessary construct in Python, they’re mostly used for code simplification, readaibility and reusability. We’ll walk through some examples to try and make that a little clearer. Creating a class and an instance of a class Let’s start […]

Read more
Django, Python

Django: File uploads in forms

There are so many usecases where you’ll want to be able to upload a whole bunch of files to a website at once and yet, there isn’t really a well documented way to do it. The Django documentation itself is a bit half baked and not really all that helpful. So, in this article, I’m […]

Read more
Django, Python

Building an app in Django: the login

I’ve spoken in depth about getting Django ready to use in this article, so I’m not going to go through the general setup commands in too much detail. Suffice to say, once you’ve got your server up and running, you’ll want to configure the firewall and start your Django app. Now, to create your login […]

Read more
Django, Python

Pulling data from MySQL into Google Charts using Django

Pulling data from MySQL into Django is pretty straightforward. This article will show you some code samples of exactly that. In the below, you’ll see I have a load of DB queries. Each query is handled in a specific way and then a value is returned. Those values are populated into the Python dictionary at […]

Read more
Django, Python

An in depth look at Django

In Django, we have a few concepts. We have projects, apps, views, models, templates and a few more bits and bobs. In this article, I want to go through  Django Project App Views.py Models.py Templates admin.py Project Config Settings.py Urls.py So how do all of these things work and how do they link together? When […]

Read more
Django, Python

Making a random password generator website with django

While learning Django, it’s important to have some real world problems to tackle. Strong passwords are of course really important and so generators have become popular. So, the first thing we do is edit our urls.py file. Here, we list the URL’s the user will access and the view they point to in our views.py. […]

Read more
Django, Python

A guide to using templates in django

In Django, we have a few concepts: URLs, Views and Templates (models too, but we’ll talk about them in a future article). You can think of the flow like this: User requests a particular web page Request checks urls.py to see if the URL exists & which view it relates to Looks up that view […]

Read more
Django, Python

Getting django setup and ready to use

I am not the biggest fan of sys admin kind of tasks – I really just want an environment that works so that I can get to work. So when it came to installing a fresh version of Django, I started looking around for easier ways to do it. Enter Linode. Linode are a VPS […]

Read more
Python

Making a simple command line to do list in Python

I’ve been asked recently what some super simple tasks would be to support learning Python so I’ve decided to post a few of them. Yesterday, you may have seen my article, looking at how we might create a command line quiz, with a time limit. Today, I am going to look at how we might […]

Read more