Python Context Managers

Introduction One of the most “obscure” features of Python that almost all Python programmers use, even the beginner ones, but don’t really understand, is context managers. You’ve probably seen them in the form of with statements, usually first encountered when you learn opening files in Python. Although context managers seem a little strange at first, when we really dive into them, understand the motivation and techniques behind it, we get access to a new weapon in our programming arsenal. So […]

Read more

Introduction to Python Iterators

What are Iterators? An iterator in Python refers to an object that we can iterate upon. The iterator consists of countable values, and it is possible to traverse through these values, one by one. The iterator simply implements the Python’s iterator protocol. The iterator protocol is a Python class which comes with two special methods, namely __iter__() and __next__(). With these two methods, the iterator is able to compute the next value in the iteration. With iterators, it is easy […]

Read more

Dockerizing Python Applications

Introduction Docker is a widely accepted and used tool by leading IT companies to build, manage and secure their applications. Containers, like Docker, allow developers to isolate and run multiple applications on a single operating system, rather than dedicating a Virtual Machine for each application on the server. The use of these more lightweight containers leads to lower costs, better resource usage, and higher performance. If you’re interested in reading more, you should take a look at Docker: A High […]

Read more

Getting Started with MySQL and Python

Introduction For any fully functional deployable application, the persistence of data is indispensable. A trivial way of storing data would be to write it to a file in the hard disk, but one would prefer writing the application specific data to a database for obvious reasons. Python provides language support for writing data to a wide range of databases. Python DB API At the heart of Python support for database programming is the Python DB API (PEP – 249) which […]

Read more

Lambda Functions in Python

What are Lambda Functions? In Python, we use the lambda keyword to declare an anonymous function, which is why we refer to them as “lambda functions”. An anonymous function refers to a function declared with no name. Although syntactically they look different, lambda functions behave in the same way as regular functions that are declared using the def keyword. The following are the characteristics of Python lambda functions: A lambda function can take any number of arguments, but they contain […]

Read more

Big O Notation and Algorithm Analysis with Python Examples

There are multiple ways to solve a problem using a computer program. For instance, there are several ways to sort items in an array. You can use merge sort, bubble sort, insertion sort, etc. All these algorithms have their own pros and cons. An algorithm can be thought of a procedure or formula to solve a particular problem. The question is, which algorithm to use to solve a specific problem when there exist multiple solutions to the problem? Algorithm analysis […]

Read more

The Best Data Science Libraries in Python

Preface Due to its exceptional abilities, Python is the most commonly used programming language in the field of Data Science these days. While Python provides a lot of functionality, the availability of various multi-purpose, ready-to-use libraries is what makes the language top choice for Data Scientists. Some of these libraries are well known and widely used, while others are not so common. In this article I have tried to compile a list of Python libraries and categorized them according to […]

Read more

Stacks and Queues in Python

Introduction Data structures organize storage in computers so that we can efficiently access and change data. Stacks and Queues are some of the earliest data structures defined in computer science. Simple to learn and easy to implement, their uses are common and you’ll most likely find yourself incorporating them in your software for various tasks. It’s common for Stacks and Queues to be implemented with an Array or Linked List. We’ll be relying on the List data structure to accommodate […]

Read more

Understanding Recursive Functions with Python

Introduction When we think about repeating a task, we usually think about the for and while loops. These constructs allow us to perform iteration over a list, collection, etc. However, there’s another form of repeating a task, in a slightly different manner. By calling a function within itself, to solve a smaller instance of the same problem, we’re performing recursion. These functions call themselves until the problem is solved, practically dividing the initial problem to a lot of smaller instances […]

Read more

Linked Lists in Detail with Python Examples: Single Linked Lists

Linked lists are one of the most commonly used data structures in any programming language. In this article, we will study linked lists in detail. We will see what are the different types of linked lists, how to traverse a linked list, how to insert and remove elements from a linked list, what are the different techniques to sort a linked list, how to reverse a linked list and so on. After reading this article, you should be able to […]

Read more
1 861 862 863 864 865 910