Introduction Given a directory path on the file system, the following Python code snippets retrieve a list of file names and total count using different methods. You may use the one that best suite your needs or find it more elegant. Let us get started… Using glob module In this example, we are going to
Introduction Concurrency and parallelism are often used interchangeably in computing, however they do not necessarily mean the same thing. If you Google concurrency vs parallelism, you will find different articles explain it differently. I think part of the confusion comes from the way people define these terms. In this post, I am not going to
Set vs list in Python A better way to understand the key difference between sets and lists in Python is to understand the definition regardless of language or syntax. Generally speaking, a set is a mathematical concept which refers to a collection of distinct objects (in math they are called elements). Distinct means there are
Introduction This question is frequently asked on many technical websites. Before we clarify the key difference between the two, please note that xrange is a Python 2.x function. In other words, Python 2.x has both range and xrange. On the other hand, in Python 3.x there is only one function called range. So this question
Introduction This is a commonly asked question among beginners and students. In this post, we are going to clarify the main differences between the two terms by providing basic definitions as well as indicating why (when) they are used. Let us begin with encoding… What is encoding? Encoding is the process of transforming data (ex.
Even though it may seem obvious that a digital signature and digital certificate are two different things, yet this question is commonly asked specially by those who are new to information security. In this post, I am going to provide a brief answer, however I will include a link to a more detailed article for
Introduction Selection sort is a simple in-place (i.e. no auxiliary memory) comparison based sorting algorithm. It is an inefficient algorithm with O(n2) running time as it uses two nested loops. Here is a summary of steps how the algorithm works: Given an unsorted list Start with the first element on the left side Scan all
Introduction Insertion sort is a simple in place (i.e no need for an auxiliary memory) sorting algorithm. It is an efficient algorithm for small data sets, specially for lists that are partially sorted. For more information about how sorting works, you may refer to the following article For more in depth information about insertion sort
Problem Implement merge sort algorithm in Python. Solution For definition and explanation, You may refer to the following post. This post is just a rewrite in Python. Before jumping directly to the code, check out the following nice YouTube clip Recursive merge sort in python Take a look at the comments for explanation… Thanks for
Table of contents Introduction What is an iterator? Iterator example What is an iterable? Iterable example – separate class Iterable example – single class Python containers What are generators? Generator types Generator function example Generator comprehension example Generator advantages Summary References Introduction Today, we are going to discuss a little bit confusing topic in Python