
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 33676 Articles for Programming

96K+ Views
Python has a built-in method called values() that returns a view object. The dictionary values are listed in the view object. We can use the values() method in Python to retrieve all values from a dictionary. Python's built-in values() method returns a view object that represents a list of dictionaries containing every value. In this article, we are going to see about the various ways to print all the values of the given dictionary in Python. Using dict.values() Method Python's dict.values() method can be used to retrieve the dictionary values which can be printed using the print() function. Example Following ... Read More

107K+ Views
A Python dictionary is an unordered collection of data values. It contains a key-value pair, in contrast to other data structures that only include one value per entry. In this article, we are going to see the various ways to print all the keys of a dictionary in Python. Using dict.keys() Method Python's dict.keys() method can be used to retrieve the dictionary keys, which can be printed using the print() function. This method returns a list object, which contains every key in the dictionary. The dictionary elements can be accessed using the dict.keys() method, just like we do with a list ... Read More

9K+ Views
When we open a file using the Python's built-in function open(), then the data temporarily stored in memory can be managed by setting the buffering parameter in the function. Buffering helps to improve the performance of opening a file by reducing the number of interactions with the disk during file input/output operations. Understanding the Buffering Parameter The buffering parameter in Python's open() function allows us to define how much data is stored in memory before being written to or read from the file. This buffering parameter is used to handle file operations with large data or frequent writes. Syntax Here ... Read More

1K+ Views
When the U modifier is used while opening a file then Python opens the file in Universal Newline mode. This mode enables Python to automatically detect and handle all common newline characters including , \r and \r during file reading. It is particularly useful when working with text files generated on various operating systems such as Windows, macOS or Linux which use different newline conventions. The U mode was used in Python 2 and early Python 3 versions to enable newline normalization. It allowed consistent handling of line endings regardless of the platform on which the file was created. However, ... Read More

13K+ Views
When we use the b modifier while opening a file, then the file is opened in binary mode. Any file whose format doesn't consist of readable characters is referred to as a "binary" file. Binary files include audio files like MP3s, text formats such as Word or PDF, and image files such as JPEGs or GIFs. Normally, the files are automatically opened in text mode in Python. When choosing a mode, include the letter "b" for binary mode. By default, the open() function opens a file in text format. As a result, the "wb" mode opens the file in binary format ... Read More

8K+ Views
When working with files in Python, it's crucial to understand the different modes in which files can be opened. Each mode defines specific operations you can perform whether reading, writing, appending, or handling binary data. Following are the common file modes in Python. Read Mode: 'r' Write Mode: 'w' Binary Mode: 'b' Append Mode: 'a' Read Mode: 'r' The default mode for opening files in Python is read mode ('r'). This allows you to read the contents of a file without modifying ... Read More

3K+ Views
Monitoring file access times is a common requirement for auditing, data management and cleanup of the scripts. Python provides multiple ways to retrieve the last access time of a file using the os and pathlib modules. Using os.path.getatime() Method In Python, we can use the os.path.getatime() method to retrieve a path's most recent access time. The path that we need to verify for the access time is taken as the input argument by os.path.getatime() method. This method returns the amount of time since the epoch, as a floating point value. It throws one OSError if the requested path cannot be ... Read More

793 Views
Swap files and temporary files are common byproducts of text editors such as Vim, Emacs or even modern IDEs. These files—often with extensions like .swp, .swo, .tmp or .bak are used to store session data or backup content temporarily. These are useful during editing sessions in which they can clutter our project directories or interfere with version control systems if not cleaned up. In this article, we are going to explore how we can leverage Python to automatically find and delete these unwanted swap files from our workspace. Using os.walk() for Recursive Deletion In this approach we use Python's os.walk() ... Read More

210 Views
You can create an objectUsing new keyword.Sample obj = new Sample();Using the newInstance() method and Class.forName() method.Sample obj2 = (Sample) Class.forName("Sample").newInstance();Using the clone() method by implementing Cloneable Interface (marker).Sample obj3 = (Sample) obj1.clone();Using class loader.Object obj4 = Sample.class.getClassLoader().loadClass("Sample");Using the constructor class from lang.reflect.Class cls = Sample.class; Constructor obj = cls.getDeclaredConstructors()[0]; Sample obj5 = (Sample) obj.newInstance();

3K+ Views
Managing hidden files and folders in a directory is an essential part of building cleanup scripts or automation tools. On Windows, hidden files are not prefixed with a dot but instead they are marked using specific file attributes. In this article, we will explore how to remove those hidden files and directories programatically using Python. Filtering by Dot Prefix (Unix/Linux/macOS) On Unix-based systems, the files or folders starting with a dot "." are considered hidden. We can use this naming pattern to filter and remove hidden files. Here is an example of removing the hidden files and directories present in ... Read More