
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 10453 Articles for Python

14K+ Views
A directory is simply defined as a collection of subdirectories and single files or either one of them. A directory hierarchy is constructed by organizing all the files and subdirectories within a main directory and this is also known as root directory. These subdirectories are separated using a / operator in a directory hierarchy. In python, we have different methods to scan through a directory recursively. In this article we are going to see about each method. Using os.walk() method Using glob.glob() method Using os.listdir() method ... Read More

7K+ Views
When we are building Python applications that store or retrieve user-specific files and settings, then we will often need to access the home directory. The home directory is the default location on a computer where user-related data is stored, such as documents, configuration files, and application data. Python provides simple and cross-platform ways of finding the home directory programmatically by making it easy to write code that works on Windows, macOS, and Linux without modifications. In this article, we'll explore the different methods to get the home directory in Python. Using os.path.expanduser("~") The os.path.expanduser() is a function in Python's built-in ... Read More

7K+ Views
Directory creation is a common task for computer users. You might need to create a directory to store some files, or to place some new files inside an existing directory. In this article, you will learn how to find if a directory already exists in Python or not. A directory is a file system structure used by operating systems and software applications to organize files. It can also refer to a list of files and folders, like the current folder in Windows Explorer. Sometimes there arises a need to check whether a certain directory exists in a system or not; ... Read More

2K+ Views
In Python, sharing common data such as constants, configuration settings or shared resources among multiple files is a routine task in modular application development. The data will be centralized in a dedicated module which allows it to be maintained in one place and imported wherever needed. Before proceeding with various approaches to share data among multiple Python files, first we need to understand what is a module and what is shared data. What is a Module? A Module is a Python file (.py) that contains definitions such as variables, functions, classes or runnable code. By placing shared data in its ... Read More

11K+ Views
In most of the applications, especially in data processing, software development or testing, it is required to compare two files to detect changes, validate outputs or find discrepancies. Python offers several ways to compare files which ranges from basic line-by-line comparisons to more advanced diff utilities. Following are the key methods which are used to compare two files in python - Line-by-line comparison: This is a straightforward approach to textual differences. difflib module: This module is used to produce human-readable diffs similar to Unix’s diff command. filecmp module: This module is used for quick binary or shallow comparisons. ... Read More

7K+ Views
Venturing further into the realm of Python programming, you'll undoubtedly encounter scenarios where executing a Python file from within the Python shell becomes essential. This capability endows you with the power to test, run, and interact with your Python scripts seamlessly without exiting the Python environment. Within this article, we shall discuss some distinct methods to execute Python files within the Python shell, each offering its unique functionalities and adaptability, facilitating seamless interaction with your Python scripts. As a Python coding expert, I would walk you through each method with step-by-step explanations and examples in a lucid style that is ... Read More

23K+ Views
In Python, there are two ways to provide input information to a program. One in which we directly assign input objects to object references/variables; and the other in which the program takes user input dynamically (during runtime). Python 2.x versions use raw_input() function to take user input dynamically; whereas, Python 3.x versions use input() function. The input() function only takes input values in the form of strings, by default. In this article, we will learn how to read the input as “Numbers” in Python 3.x using input() function. Reading Inputs as Numbers Python, like any other programming languages, accepts two ... Read More

3K+ Views
Python is a high-level programming language that helps users to run a program and integrate systems more efficiently, as it executes a program in comparatively fewer lines of code. In Python programming language, a code can be executed in two ways - Interactive Mode Script Mode In this article, we will learn how to execute a Python program in script mode on Windows. However, the steps are almost the same for other operating systems.Python Script Mode Script mode in Python allows us to write Python code in files with the .py extension and run the entire program at ... Read More

2K+ Views
Python is a high-level programming language that helps a user to run a program and integrate systems more efficiently, as it executes a program in comparatively fewer lines of code. In Python programming language, a code can be executed in two ways - Interactive Mode Script Mode In this article, we will learn how to execute Python code in Interactive mode in Windows. However, the commands are almost the same in other operating systems as well. Interactive Mode Interactive mode in Python is a built-in feature that allows users to execute Python commands one line at a time. ... Read More

461 Views
The command line is the place where executable commands are given to the operating system. In Python, command-line arguments allow users to pass information to a script when it's executed from the terminal. A Python script can be executed by writing its name in front of the Python executable on the command line. Following is the example command which executes the Python file named sample.py - python sample.py If we need to pass arguments to a script, we can pass them at the time of execution, separating them by a space as shown below - python test.py Hello TutorialsPoint Python ... Read More