Month: November 2019

Generating a Dictionary Value Summary

Generate a Simple Dictionary Value Summary

Today’s post will be a short post – on something I recently needed to do for a project at work. My program assigned orders to a particular disposition. The domain of the problem isn’t really relevant – but I used a dictionary with the unique order number as the key and one of several values could be the value.

I wanted to post a message, once the process had completed, to inform me of the outcome summary. How many orders got disposition A, B, C and so on.

Continue reading “Generating a Dictionary Value Summary”

Closures and Decorators

Closures and Decorators in Python

This article will attempt to explain the related concepts of Closures and Decorators in the Python program language. It is essential to understand that functions, like literally everything else in Python, are, in fact, objects. As such, they can be passed to other functions as arguments. This fact opens up some interesting possibilities (such as the concept of closures and decorators).

It is critical to have a handle on closures to understand decorators, so we will start there.

Continue reading “Closures and Decorators”


Objectives Of This Post

Continuing my Python Series (see my first post here and second one here), I went through how to use List, Set and Dictionary Comprehensions, in Python, to replace loops that generate collections of items. In this post, we will explore Lambdas.

What Are Lambdas?

A Lambda Function is a concise way to define a limited anonymous function in Python. Here is an example of an identity function as a standard python function, and then the same function expressed as a Lambda function.

Continue reading “Lambdas”

List Comprehensions

Self Learning

Objectives Of This Post

This post is the first in what I intend to be a series of posts on programming in Python. I put together a fair bit of Python code for my job in my role as an analyst. But most of that code is merely gluing together snippets from the internet, as my main focus isn’t writing software but merely accomplishing a task. In this series, I hope to explain concepts with the idea that teaching the material will help me learn it better.

Continue reading “List Comprehensions”