Harshit Sachan

Harshit Sachan

25 Articles Published

Articles by Harshit Sachan

25 articles

How to Package and Deploy CLI Applications With Python

Harshit Sachan
Harshit Sachan
Updated on 27-Mar-2026 4K+ Views

Based on the interface we have two types of applications: CLI (Command Line Interface) applications and GUI (Graphical User Interface) applications. A command line application or console application is one which can be accessed from a shell or command line through a text interface. These accept inputs from the user in text format, unlike GUI applications which provide a graphical interface containing buttons, text boxes and icons. Python is a popular programming language for developing CLI applications. Let's explore the complete process of packaging and deploying CLI applications with Python using built-in and external tools. Step 1: ...

Read More

Command Line File Downloader in Python

Harshit Sachan
Harshit Sachan
Updated on 27-Mar-2026 863 Views

Python provides powerful libraries for creating command line applications. A command line file downloader allows you to download files from the internet directly through your terminal without using a browser. This tutorial shows how to build a simple file downloader using Python's requests and argparse libraries. The application accepts a URL and filename as command line arguments and downloads the file to your local system. Required Libraries We need two Python libraries for this project: requests − For making HTTP requests to download files argparse − For handling command line arguments Install the ...

Read More

Connect new point to the previous point on a image with a straight line in OpenCV-Python

Harshit Sachan
Harshit Sachan
Updated on 27-Mar-2026 1K+ Views

In OpenCV-Python, we can draw lines between points on an image to create paths, track movements, or create interactive drawing applications. This is particularly useful for computer vision applications where user interaction is required. OpenCV (Open Source Computer Vision Library) provides powerful functions for image manipulation and computer vision tasks. In this article, we will learn how to connect mouse-clicked points on an image with straight lines using OpenCV-Python. Understanding the cv2.line() Function To draw a straight line between two points, OpenCV provides the cv2.line() function with the following syntax: cv2.line(image, start_point, end_point, color, thickness) ...

Read More

Convert BGR and RGB with Python and OpenCV

Harshit Sachan
Harshit Sachan
Updated on 27-Mar-2026 13K+ Views

OpenCV is a library of programming functions primarily for real-time computer vision. The library is cross-platform and licensed as free and open source software under the Apache License. It is written in C++ and has Python bindings that make it easy to use in Python applications. In this article, we will learn how to convert between BGR and RGB color formats using Python and OpenCV. Before proceeding, let's understand what BGR and RGB are and why conversion is necessary. What are BGR and RGB? RGB and BGR are both color models used to represent colors in digital ...

Read More

How to Package a Command Line Python Script

Harshit Sachan
Harshit Sachan
Updated on 27-Mar-2026 3K+ Views

Python is a powerful programming language widely used for creating various applications, including command-line interface (CLI) scripts that automate tasks. To share these scripts with others, you need to package and distribute them properly. This article will guide you through the complete process of packaging a Python command-line script, making it easy to distribute and install. Step 1: Create a Virtual Environment First, create an isolated environment for your project to manage dependencies effectively ? python -m venv myproject_env Activate the virtual environment ? # On Windows myproject_env\Scripts\activate # On ...

Read More

Command Line Scripts - Python Packaging

Harshit Sachan
Harshit Sachan
Updated on 27-Mar-2026 460 Views

Python command line interface (CLI) scripts are programs that perform specific tasks when executed from the command line. These scripts help automate repetitive tasks and can be packaged for easy distribution to other developers. This article covers the complete process of creating, packaging, and distributing Python CLI scripts. Creating the CLI Script First, let's create a simple CLI script that accepts command line arguments using the argparse library ? import argparse def greet(name): print(f"Hello, {name}!") def main(): parser = argparse.ArgumentParser(description="A simple greeting CLI tool") ...

Read More

Python Program to sort a tuple of custom objects by properties

Harshit Sachan
Harshit Sachan
Updated on 27-Mar-2026 508 Views

Python allows us to create custom objects using classes to represent complex data structures. When we have a tuple containing these custom objects, we often need to sort them by specific properties like name, age, or other attributes. A custom object is an instance of a user-defined class that encapsulates data and behavior specific to our needs. Here's how we define a simple class ? class Person: def __init__(self, name, age): self.name = name self.age = age ...

Read More

Python Program to Replace Elements in a Tuple

Harshit Sachan
Harshit Sachan
Updated on 27-Mar-2026 5K+ Views

In this article, you will learn how to replace elements in a tuple using Python. Since tuples are immutable, we cannot directly modify their elements. Instead, we need to use specific techniques to create new tuples with updated values. Before exploring the replacement methods, let's understand what tuples are in Python. What is a Tuple in Python? A tuple is one of Python's four built-in data types for storing collections. The other three are list, set, and dictionary, each with unique features and applications. Tuples are ordered and immutable collections. We create tuples by placing elements ...

Read More

Python Program to search an element in a tuple

Harshit Sachan
Harshit Sachan
Updated on 27-Mar-2026 7K+ Views

In Python, searching for elements within a data structure is a common task and different types of data structures should aim to provide efficient methods for searching. The problem of searching involves finding a specific element within a container and returning a value indicating whether it was found or not. One data structure that can be used for this task is a tuple, which stores a collection of different types of data in a single variable. These items can be accessed by their index and Python offers various methods to work with them. Tuples are immutable, meaning that once ...

Read More

Python Program to check if the tuple is empty

Harshit Sachan
Harshit Sachan
Updated on 27-Mar-2026 4K+ Views

In Python, checking if a tuple is empty is a common operation needed to determine what actions to take in a program. A tuple is an ordered collection of items that is immutable, meaning its contents cannot be changed after creation. A tuple is considered empty if it contains zero elements. Python provides several methods to check for empty tuples, each with different advantages. What is a Tuple? A tuple in Python is defined using parentheses and can store heterogeneous data ? # Creating tuples non_empty_tuple = (1, 'a', 3.7) empty_tuple = () print("Non-empty ...

Read More
Showing 1–10 of 25 articles
« Prev 1 2 3 Next »
Advertisements