Photo by Alexander Andrews on Unsplash

Understanding the internals of Instance Creation in Python

In this article, we’ll take a deep dive into exactly what happens when we instantiate a new object in Python. With this knowledge in hand, we can exercise fine control over instance creation, which can allow us to customize Python objects in powerful ways. So let’s get started.

So what happens behind the scenes when we create a new object in Python?

Let’s try to understand this using a basic class example that models Employee entity.

Photo by Fumiaki Hayashi on Unsplash

Understanding what, when & why to use closures!

Closures are elegant Python constructs. In this article, we’ll learn about them, how to define a closure, why and when to use them.

But before getting into what a closure is, we have to first understand what a nested function is and how scoping rules work for them. So let’s get started.

Scoping Rules and Nested Functions in Python

Whenever a function is executed, a new local namespace is created which represents the local environment that contains names of function parameters and variables assigned inside the function body. …

Photo by Marcus Urbenz on Unsplash

Python provides us the capability to execute a directory or a zip file directly. Something which is not widely known in the Python community. Therefore, this blog post aims to uncover that. Also, in the process, we’ll acquire few less-known python tricks up our sleeves. So let’s dig in.

It is very straightforward to execute a directory in Python. All we have to do is make sure there is a file present in that directory. Let’s understand it by considering an example. Here we have a file with the following contents:

-serve Photo by Joseph Barrientos on Unsplash

Understanding various types of services in Kubernetes

Understanding networking in Kubernetes is paramount. Understanding Services can let us enable our pods to talk to each other and choose the right strategy based on the origin of traffic (either from within or outside the cluster) for our user-defined applications and services.

This article aims to cover the significance of Services in a Kubernetes cluster, the various shortcomings they overcome, followed by various types of Services objects offered by k8, their capabilities, and when to use each one of them.

NOTE: To avoid any confusion between the two services terms we’ll be using throughout, one refers to the Services…

Understanding Convolutional, Pooling and Fully Connected layers of CNN

Deep learning in computer vision has made rapid progress over a short period. Some of the applications where deep learning is used in computer vision include face recognition systems, self-driving cars, etc.

This article introduces convolutional neural networks, also known as convnets, a type of deep-learning model universally used in computer vision applications. We’ll be deep-diving into understanding its components, layers like convolutional layer, pooling layers, and fully connected layers and how they can be applied to solve various problems.

So let’s get started.

The objective of CNNs:


Above is an image of a cat, as a kid we are told that this animal…

Photo by Prateek Katyal on Unsplash

Exploring some of the unfamiliar yet cool Python features

Python has lots of cool features such as first class functions, lambdas, generators, comprehensions etc. There are plenty of articles on the subject. However, there are some of the features in Python, which are generally not so commonly used.

In this article, we’ve tried to summarize some of the these features, which will provide us a better knowledge on the subject and can come in handy at times for developers.

So let’s dive in!

1. Limiting CPU and Memory Usage

Resources like CPU, memory utilised by our Python program can be controlled using the resource library.

To get the processor time (in seconds) that a process…

Photo by Fabrizio Verrecchia on Unsplash

Understanding the advantage of using datetime over time module

Coordinated Universal Time (UTC) is the standard, time-zone independent representation of time. UTC works great for computers that represents time as seconds since the UNIX epoch (starting point against which we can measure the passage of time).

For example, if we define the epoch to be midnight on January 1, 1970 UTC — the epoch as defined on Windows and most UNIX systems — then we can represent midnight on January 2, 1970 UTC as 86400 seconds (24 * 60 * 60) since the epoch.

But UTC isn’t ideal for humans. Since we usually refer time relative to where we’re…

Understanding the single expression functions in Python

In this article, we’ll learn about the anonymous function, also known as lambda functions. We’ll try to decode as to why there’s a big fuss about lambdas, understand their syntax and when to use them.

So Let’s jump right in.

The lambda keyword in Python provides a shortcut for declaring small anonymous functions. Lambda functions behave just like regular function declared with def keyword. They can be used whenever function objects are required.

For example, this is how we’d define a simple lambda function carrying out an addition:

Photo by Ashes Sitoula on Unsplash

Understanding the usage of generators and yield in Python

This article details how to create generator functions and why we would want to use them in the first place.

The simplest choice for functions that produce a sequence of result is to return a list of items. For example, let’s say we need to find the index of every word in the string. Here, we accumulate results in a list using the append method and return it at the end of the function.

This works as…

Photo by American Public Power Association on Unsplash

Understanding Array Data Structures in Python

An array is a fundamental data structure available in most programming languages, and it has a wide range of uses across different algorithms.

In this article, we’ll take a look at less known array implementation in Python that only use core language features that’s included in Python standard library.

We’ll see the strengths & weaknesses of each approach so we can decide which implementation is right for our use-case. But before we jump in, let’s cover some of the basics first.

How do arrays work, and what are they used for?

Arrays consist of fixed-size data records that allow each…

Rachit Tayal

Sports Enthusiast | Senior Deep Learning Engineer. Python Blogger @ medium. Background in Machine Learning & Python. Linux and Vim Fan

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store