
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

14K+ Views
The common header format of Python files is a simple and essential element in any Python script. The Header Format is just an introduction that provides context. In Python, we commonly use a docstring as the header format. A docstring is a special kind of comment enclosed within triple quotes, i.e., either single or double. It's placed right at the beginning of the script, even before any import statements, making it easily visible and accessible to anyone who reads the code. The standard structure of a Python file header is adorned with a docstring. Following is an example of ... Read More

8K+ Views
What are Python File Extensions? Python file extensions are the suffixes that are added to the end of file names, which indicate the type of content inside the file and how it relates to the Python programming environment. These extensions help the interpreter, operating system, and developers understand how to process or execute the file. The .py, .pyc, .pyo, and .pyd files are the most commonly used Python file extensions and have their significance when it comes to executing python programs. Here are the Python file extensions and their descriptions - .py: The input source code that you've written. ... Read More

40K+ Views
We usually write programs in Python and save the file with .py extension. However, there is another file type called .pyc, which is automatically generated by the Python interpreter while executing the source code. What is a .pyc File? When you execute a Python program, the Python interpreter doesn't directly execute the .py file; instead, it parses the source code, compiles it into bytecode(a low-level representation of the Python source code), and stores it as the .pyc file. Further, this bytecode is executed with the Python Virtual Machine (PVM). A .pyc file is usually created when a Python program is ... Read More

54K+ Views
It is a common and routine task in Python; the act of writing binary data to a file when you need to save non-textual data such as images, audio files, or serialized objects. In this article, we will explore various ways how you can write binary data to a file using Python and provide you with code examples followed by comprehensive explanations to help you grasp the concept. To write binary data to a file in Python, you can follow these steps: Open the File in Binary Mode First, you should proceed to open the file in ... Read More

14K+ Views
The creation and modification datetime of a file in Python are defined as the timestamps associated with the events of when the file was created and when it was last modified. Creation datetime: It is defined as the timestamp when a file was initially created or added to the file system. Modification datetime: It is defined as the timestamp when the file's content was last modified or updated. These datetimes can provide a lot of information such as the file's age, recent changes, or when it was first introduced. In Python, you can fetch the ... Read More

482 Views
There will be times when we need to remove files programmatically in Python. Removing files, in this context, is the act of deleting or erasing files from a computer's file system using Python programming language. You must know that when you remove a file, it is permanently deleted from the storage location; this frees up disk space and makes the file inaccessible. Python has a number of modules and functions, such as os.remove() or os.unlink(), that permit you to interact with the operating system and remove files using code. This functionality is particularly useful when we want to automate tasks, ... Read More

1K+ Views
You can use the tempfile module to create a unique temporary directory in the most secure manner possible. There are no race conditions in the directory’s creation. The directory is readable, writable and searchable only by the creating user ID. Note that the user of mkdtemp() is responsible for deleting the temporary directory when done with it. To create a new temporary directory, use it as follows −import tempfile _, temp_dir_path = tempfile.mkdtemp() # Do what you want with this directory # And remove the directory when doneNote that you need to manually delete this directory after you're done with ... Read More

949 Views
Temporary files are created to store data temporarily during the execution of a program or while working with large amount of data. To create a temporary file we can use the tempfile module, as it creates unique names and stores in platform-dependent default location . Specifically the tempfile module is used as the files created using this module are deleted as soon as they are closed. Creating a Temporary File A temporary file is created using the TemporaryFile() function of the tempfile module. This by default opens the file in 'w+b' mode, which allows to both read and write the ... Read More

4K+ Views
The act of renaming multiple files recursively in Python can be a useful task when it is required to change the names of multiple files within a directory and its subdirectories. If you need to replace certain characters, add prefixes or suffixes, or completely change the file names, Python has powerful tools to accomplish such operations. In this article, we explore a few different approaches to renaming multiple files recursively using Python. We consider some code examples, each demonstrating a unique method to achieve this task. So let us get started right away and learn how to rename multiple files ... Read More

11K+ Views
There are times when you want to organize your files or update the directory names to better reflect their contents. In such scenarios, the operation of renaming directories becomes helpful and it is a common task that we often encounter in Python file management. There is provision of several modules and methods in Python that makes renaming directories an easy task. In this article, we explore different ways how you can rename directories using Python code. You will learn this skill by practicing the code examples and explanations discussed in this article. Making Use of the OS Module ... Read More