
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 26504 Articles for Server Side Programming

2K+ Views
Through the command line, we can easily create dynamic scripts that modify or generate files based on user input. This functionality is useful for generating logs, exporting data, or saving outputs from calculations. The following are the basic steps we need to follow to write data into a file from the command line - Accept the file name and optional data from the command line. Open the specified file in write mode. Write the content to the file. Handle possible errors such as ... Read More

12K+ Views
Reading files from the command line is a common task in many Python scripts and automation workflows. Whether we’re building a simple utility to process text files or developing a complex data analysis tool that being able to accept file input directly from the command line, which enhances the flexibility and usability of our program. Python provides built-in modules such as sys and argparse that make our task straightforward and efficient. In this article, we are going to see the different methods that are used to read a file from the command line using Python - Using sys.argv() In Python, ... Read More

25K+ Views
Importing Python Modules by Full Path Python has various tools to import modules dynamically, where the full path is accessible. In this article, we will explore various methods to import Python modules when the full path is given, and each method has its own advantages for various use cases. In Python, it is common to import modules using statements such as import os or from mypackage, import utils. But, Imagine a situation, Where we need to import the Python module given the full path, Let's dive into the article to learn more about it. Using importlib.util.spec_from_file_location() The Python provides functions ... Read More

11K+ Views
In PHP, we can execute Python scripts using built-in functions such as shell_exec(), exec() or popen() by enabling seamless integration between the two languages. Below are three methods to run a Python script from PHP with examples and explanations of each - Using 'shell_exec()' function One way to execute a Python script is by using the shell_exec function. This function runs a command via the shell and returns the output as a string. This function ensures that the command is safe to run by escaping any characters that could be harmful. The output of this script is sent back to ... Read More

5K+ Views
In Python, it is possible to source one Python file from another, which enables us to share data between scripts. In this article, we will go through the different ways to source a Python file from another Python file. Understanding Python File Importing In Python, the process of importing makes to use functions, classes, and variables defined in one Python file within another. This helps us in code reusability and enables us to split our code into multiple files based on functionality. Using the import Statement One of the most common ways to import a Python file is by using ... Read More

632 Views
In Python, the underscore (_) is a special character with different meanings based on how and where it is used. It plays a significant role in readability, naming conventions, and interpreter behavior. In this article, we will discuss different scenarios of using the Underscore(_) in Python. Single Underscore _ in Python The single underscore (_) is used in Python for special purposes, which depend on the context. These are one of the most versatile and commonly seen symbols in clean and Pythonic code. Use Cases of _ (Single Underscore) The single underscore(_) can be used in different use cases. Let's ... Read More

60K+ Views
In Python, it is often necessary to execute another file. This is common in cases such as running helper scripts, triggering workflows, or executing test cases. Python provides several ways to execute one file using another. Depending on the requirement, whether we want to reuse functions, execute a file directly, or run it as a subprocess. Let us look at these solutions one by one - Understanding Python Script Execution Before proceeding with how to run one Python file from another, it's important to understand how Python scripts are executed. When we run a Python file using python myscript.py ... Read More

3K+ Views
In Python, while working with files, we may need to duplicate binary files. In this article, we will go through various ways to explore efficient methods of copying binary files in Python. First, we need to understand about Binary format and Binary File Copying, before proceeding with various ways to copy a binary file. What is Binary Format? Binary format is a method of storing data in the form of binary digits, such as 0s and 1s. Unlike text format, which represents data using readable characters like letters and numbers, binary format stores data as raw byte sequences. Binary file ... Read More

2K+ Views
Searching for specific files in a directory is a difficult task, and this can be accomplished by using different tools in Python. In this article, we will see how to find all the files in a directory with an extension .txt using Python. Here are the different approaches, let's see one by one in detail - Using os.listdir() The os.listdir() is a function from Python's built-in os module which returns a list of names, i.e., as strings, of the entries in the directory given by the path. Example In this example, we will use the function in Python's os.listdir() to ... Read More

906 Views
Among several file-handling operations in Python, the need to list all files in a directory is the most common one, and it's quite straightforward. Python offers a module named os that provides functions to work with the operating system, the directories, and the files seamlessly. In this article, we will cover ways of listing all files in a directory. The following are the different methods used to list all files in a dictionary using Python - os.listdir(): list all files in a directory os.walk(): Recursively lists all files in subdirectories ... Read More