Sarika Singh

Sarika Singh

142 Articles Published

Articles by Sarika Singh

Page 7 of 15

How to find which Python modules are being imported from a package?

Sarika Singh
Sarika Singh
Updated on 24-Mar-2026 13K+ Views

A module in Python is a file containing Python code, functions, classes, or variables. Packages are collections of modules organized in directories. When working with large applications, it's often useful to know which modules are currently imported and available in your Python environment. In this article, we will discuss various methods to find which Python modules are being imported from a package. Using sys.modules with List Comprehension The sys.modules dictionary contains all currently loaded modules. We can use list comprehension to extract module names efficiently. Example The following example returns all imported module names in ...

Read More

How we can bundle multiple python modules?

Sarika Singh
Sarika Singh
Updated on 24-Mar-2026 2K+ Views

Working with complex programs that span thousands of lines creates two fundamental problems: managing code to locate specific functionality and debugging errors efficiently. Python solves this by allowing you to break code into multiple modules and bundle them into a single executable script. Python provides functionality to bundle different modules into a single executable, enabling easier management and debugging of complex programs. Method 1: Using ZIP Files You can bundle multiple Python modules by creating a ZIP file and executing it directly. The key requirement is having a main.py file as the entry point. Syntax ...

Read More

How to delete an installed module in Python?

Sarika Singh
Sarika Singh
Updated on 24-Mar-2026 38K+ Views

Python provides several methods to uninstall installed packages. The most common approaches are using pip (Python's default package manager) or conda (for Anaconda/Miniconda environments). Uninstalling a Package Using pip The pip command is Python's standard package manager. It allows you to install, upgrade, and uninstall Python packages from the Python Package Index (PyPI). Basic Syntax pip uninstall package_name Example: Uninstalling scipy Here's how to uninstall the scipy package using pip ? pip uninstall scipy The output will show the files to be removed and ask for confirmation ? ...

Read More

How to install a Python Module?

Sarika Singh
Sarika Singh
Updated on 24-Mar-2026 15K+ Views

A Python module is a file containing Python definitions and statements. Modules help us organize code into smaller, manageable pieces and enable code reuse across multiple programs. To use external modules in your Python projects, you need to install them using package managers like pip or conda. Using PIP to Install Modules PIP is the standard package manager for Python modules. It comes pre-installed with Python 3.4 and later versions. Use pip to install packages from the Python Package Index (PyPI). Installing a Package Open a command prompt or terminal and use the following command to ...

Read More

How to list all functions in a Python module?

Sarika Singh
Sarika Singh
Updated on 24-Mar-2026 52K+ Views

In this article we will discuss how to list all the functions in a Python module. A Python module contains multiple different functions that allow for extensive code reusability making complex code simple. It also enhances portability of python program by changing platform dependent code into platform independent APIs. Python standard library consists of modules written in C that provide access to system functionality and modules written in python that provide general solutions for everyday problems making the life of programmers easy as it prevents writing of long code for simple problems. Using dir() to get functions ...

Read More

How to remove all leading whitespace in string in Python?

Sarika Singh
Sarika Singh
Updated on 24-Mar-2026 18K+ Views

Leading whitespace refers to any spaces, tabs, or other blank characters that appear at the start of a string. These characters come before the first visible text and can affect how the string is displayed or processed. Python provides several methods to remove leading whitespace from strings. The most common and recommended approach is using the lstrip() function. Using the lstrip() Function The lstrip() function removes all whitespace characters from the beginning (left side) of a string. It does not affect any whitespace at the end or in the middle of the string. Syntax ...

Read More

How to join two strings to convert to a single string in Python?

Sarika Singh
Sarika Singh
Updated on 24-Mar-2026 2K+ Views

In Python, we can join two strings into one single string using different approaches. Each method has its own advantages depending on the use case. Using + Operator The most common way to combine two strings is by using the + operator. It concatenates strings exactly as they are, without any automatic separator ? str1 = "Hello" str2 = "World" # Direct concatenation without space result1 = str1 + str2 print("Without space:", result1) # Adding space manually result2 = str1 + " " + str2 print("With space:", result2) Without space: HelloWorld ...

Read More

How to check if a character is upper-case in Python?

Sarika Singh
Sarika Singh
Updated on 24-Mar-2026 44K+ Views

In this article, we are going to find out how to check if a character is an uppercase letter in Python. We will explore four different approaches ? Using the isupper() method Using regular expressions Using ASCII values Direct comparison In each approach, we will check whether a given character is in uppercase and return True or False accordingly. Using the isupper() Method The first and most straightforward way is by using the built-in isupper() method. This method ...

Read More

How to check if text is “empty” (spaces, tabs, newlines) in Python?

Sarika Singh
Sarika Singh
Updated on 24-Mar-2026 5K+ Views

In this article, we will explore different methods to check if text contains only whitespace characters (spaces, tabs, newlines) or is completely empty in Python. Using isspace() Method The isspace() method determines whether a string contains only whitespace characters. It returns True if the string consists entirely of spaces, tabs, newlines, or other whitespace characters; otherwise, it returns False. Note that isspace() returns False for empty strings ⁠— it only detects strings with whitespace content. Example Let's test different strings to see how isspace() behaves ⁠— text1 = " " ...

Read More

How to check if a unicode string contains only numeric characters in Python?

Sarika Singh
Sarika Singh
Updated on 24-Mar-2026 1K+ Views

In Python, Unicode strings can contain numeric characters from various languages and scripts. To check if a Unicode string contains only numeric characters, we can use built-in string methods, regular expressions, or character iteration. These methods ensure that characters like Arabic numerals, Chinese digits, or superscripts are also recognized as valid numeric characters. Using isnumeric() Method The isnumeric() method returns True if all characters in the string are numeric, including Unicode numeric characters like ², ١, 一, etc. If any character is non-numeric or the string is empty, it returns False. Example: Unicode Numeric Characters ...

Read More
Showing 61–70 of 142 articles
« Prev 1 5 6 7 8 9 15 Next »
Advertisements