Found 34494 Articles for Programming

How to create a zip file using Python?

Sarika Singh
Updated on 25-Aug-2023 01:02:19

53K+ Views

ZIP is an archive file format used to for lossless data compression. One or more directories or files are used to create a ZIP file. ZIP supports multiple compression algorithms, DEFLATE being the most common. ZIP files have .zip as extension. In this article we are going to discuss how to create a Zip file using Python. Creating uncompressed ZIP file in Python Uncompressed ZIP files do not reduce the size of the original directory. As no compression is sharing uncompressed ZIP files over a network has no advantage as compared to sharing the original file. Using shutil.make_archive to create ... Read More

How to create a tar file using Python?

Sarika Singh
Updated on 18-Aug-2022 12:09:00

11K+ Views

Tape Archive Files is what the letter TAR in tar files stands for. Tar files are the archive files which allows you to store numerous files in a single file. Open-source software is distributed using tar files. Tar files typically end in.tar, but after they've been compressed using tools like gzip, they have the ending tar.gz. Various file modes to open Python tar file r − reads a TAR file by opening it. r − Reads an uncompressed TAR file when it is opened. w or w − Opens a TAR file for uncompressed writing a or a − ... Read More

How are entire non-empty directory trees removed using Python?

Rajendra Dharmkar
Updated on 22-Aug-2023 11:21:06

116 Views

It is very well known in the vast domain of computer programming that the efficient handling of file and directory operations is paramount to effective data management. There will be instances in our routine work, where we encounter the need to remove entire directory trees, along with all their subdirectories and files. Python, a multipurpose and powerful programming language, equips developers with a robust module called ‘shutil’ module to handle such directory tasks effectively. In this extensive tutorial, we will explore the intricate process of removing entire non-empty directory trees using Python's 'shutil' module. Throughout this article, we will present ... Read More

How is a file read using a limited buffer size using Python?

Rajendra Dharmkar
Updated on 11-Sep-2023 16:29:36

767 Views

In the world of computer programming, file handling is a very essential aspect of managing data efficiently. At times, when we are required to deal with large files, it may be that reading the entire file into memory may not be practical or efficient. In such situations, reading a file using a limited buffer size can be a more practical approach and solution. Python, a versatile and robust language, provides developers with powerful tools to perform file operations effectively. In this comprehensive article, we will explore different ways of carrying out the process of reading a file using a limited ... Read More

What is an array data structure in Java?

Sai Subramanyam
Updated on 30-Jul-2019 22:30:20

157 Views

Array is a container which can hold a fix number of items and these items should be of the same type. Most of the data structures make use of arrays to implement their algorithms. Following are the important terms to understand the concept of Array. Element − Each item stored in an array is called an element. Index − Each location of an element in an array has a numerical index, which is used to identify the element. Example Live Demo public class ArrayExample { public static void main(String args[]){ int myArray[] = {44, 69, 89, 635}; for (int i = 0; i

How an entire file is read into buffer and returned as a string in Python?

Rajendra Dharmkar
Updated on 22-Aug-2023 11:18:52

6K+ Views

In the dynamic world of computer programming, file handling, and data manipulation form the backbone of numerous tasks. Python, a powerful and versatile language, offers developers a plethora of methods to achieve efficient file operations. In this comprehensive guide, we delve into the art of reading entire files into buffers and returning them as strings in Python. With step-by-step explanations and practical code examples, we equip you with the skills to navigate the realm of file handling with finesse. Understanding File Reading and Buffering Before embarking on our code journey, it's crucial to grasp the fundamentals of file reading and ... Read More

What are the types of arrays in Java?

Lakshmi Srinivas
Updated on 30-Jul-2019 22:30:20

15K+ Views

There are two types of arrays in Java they are − Single dimensional array − A single dimensional array of Java is a normal array where, the array contains sequential elements (of same type) − int[] myArray = {10, 20, 30, 40} Example Live Demo public class TestArray { public static void main(String[] args) { double[] myList = {1.9, 2.9, 3.4, 3.5}; // Print all the array elements ... Read More

How to print characters from a string starting from 3rd to 5th in Python?

Sarika Singh
Updated on 18-Aug-2022 11:50:52

8K+ Views

Python uses arrays of bytes called strings to represent unicode characters. In Python, string indexing ranges from 0 to n-1, where n is the length of the string. In a string of size n, characters can therefore be retrieved from 0 to n-1. For instance, the index of the text “Coding” is 0, 1, 2, 3, 4, 5. The first character in the string “Coding” is represented by the number 0, and the characters o, d, i, n, and g are represented by the numbers 1, 2, 3, and 5, respectively. Printing characters of a string Characters can be put ... Read More

What is the maximum size of list in Python?

Pythonic
Updated on 30-Jul-2019 22:30:20

4K+ Views

Maximum length of a list is platform dependent and depends upon address space and/or RAM. The maxsize constant defined in sys module returns 263-1 on 64 bit system. >>> import sys >>> sys.maxsize 9223372036854775807 The largest positive integer supported by the platform's Py_ssize_t type, is the maximum size lists, strings, dicts, and many other containers can have.

What is the maximum length of string in Python?

Pythonic
Updated on 30-Jul-2019 22:30:20

5K+ Views

Maximum length of a string is platform dependent and depends upon address space and/or RAM. The maxsize constant defined in sys module returns 263-1 on 64 bit system. >>> import sys >>> sys.maxsize 9223372036854775807 The largest positive integer supported by the platform's Py_ssize_t type, is the maximum size lists, strings, dicts, and many other containers can have.

Advertisements