Programming Articles

Page 618 of 2547

Resource Usage Information using Python

Chandu yadav
Chandu yadav
Updated on 25-Mar-2026 1K+ Views

Python's resource module helps monitor and control system resource usage in UNIX-based systems. It provides methods to get resource usage statistics and set resource limits to prevent processes from consuming excessive system resources. Importing the Resource Module First, import the resource module ? import resource Resource Limits The module uses two types of limits: soft limits (current limit that can be changed) and hard limits (maximum value for soft limits). Soft limits cannot exceed hard limits, and hard limits can only be reduced. Method resource.getrlimit(resource) Returns the current soft and hard ...

Read More

Python Interface to Shell Pipelines

Ankith Reddy
Ankith Reddy
Updated on 25-Mar-2026 441 Views

The pipes module in Python provides an interface to shell command pipelines, allowing you to chain UNIX commands together. This module uses /bin/sh command line and works with os.system() and os.popen() methods internally. Note: The pipes module is deprecated as of Python 3.3 and removed in Python 3.11. For modern applications, consider using subprocess module instead. Importing the Module To use this module, import it as follows − import pipes Template Class The pipes module contains the Template class, which is an abstraction of a pipeline that allows you to build and ...

Read More

The fcntl and ioctl System Calls in Python

Arjun Thakur
Arjun Thakur
Updated on 25-Mar-2026 3K+ Views

The fcntl module in Python provides an interface to the fcntl() and ioctl() Unix system calls for file control operations. This module is essential for low-level file descriptor manipulation, file locking, and I/O control operations on Unix-like systems. All methods in this module take a file descriptor (integer) or io.IOBase object as their first argument. To use this module, import it first: import fcntl fcntl.fcntl(fd, op[, arg]) Method This method performs operations on file descriptors. The op parameter defines the operation, and the optional arg can be an integer or string. When arg is ...

Read More

POSIX Style TTY control using Python

Ankith Reddy
Ankith Reddy
Updated on 25-Mar-2026 632 Views

The termios module provides an interface to the POSIX calls for TTY I/O control. It is only available for Unix-based systems and allows you to control terminal behavior programmatically. Importing the Module To use the termios module, import it as follows − import termios All methods in this module take a file descriptor as an argument. The module provides several methods for controlling terminal attributes. Method termios.tcgetattr(fd) This method returns a list of TTY attributes for the given file descriptor. The attributes include: iflag − Input mode flags oflag − ...

Read More

How we can compress large Python files?

Niharika Aitam
Niharika Aitam
Updated on 25-Mar-2026 460 Views

Working with large files in Python can be challenging due to storage space and processing requirements. Python's zipfile module provides an effective solution for compressing files, reducing their size significantly while maintaining data integrity. Why Compress Files? File compression offers several benefits: Storage Efficiency − Reduces disk space usage Transfer Speed − Faster file uploads and downloads Memory Management − Lower memory consumption when handling files Archiving − Better organization of multiple files Basic Syntax The zipfile module provides a simple interface for creating compressed archives: import zipfile # Basic syntax zipfile.ZipFile(filename, mode, compression) Where: ...

Read More

The most Common POSIX System Calls in Python

Arjun Thakur
Arjun Thakur
Updated on 25-Mar-2026 1K+ Views

The posix module provides low-level UNIX system call functionality in Python. While you shouldn't import it directly, understanding its core functions helps you work with file descriptors and system operations through the os module. Overview The posix module works on UNIX environments and provides operating system functionality. Instead of importing posix directly, use the os module, which acts as a superset of posix on UNIX systems. On non-Unix systems, posix is not available, but os provides similar functionality with some limitations. posix.environ Constant The environ is a dictionary object containing environment variables. Keys and values are ...

Read More

Convenient Web-browser controller in Python

Chandu yadav
Chandu yadav
Updated on 25-Mar-2026 1K+ Views

To display web-based documents to users in Python, there is a module called webbrowser. It provides a high-level interface to handle web documents and control web browsers programmatically. On UNIX-based systems, this module supports lynx, Netscape, Mosaic and other browsers. For Windows and macOS, it uses the standard browsers. Importing the Module To use this module, we need to import it first ? import webbrowser Main Methods webbrowser.open(url, new=0, autoraise=True) This method opens the specified URL using the default web browser. The new parameter controls how the URL opens ? ...

Read More

Generate Secure Random Numbers for Managing Secrets using Python

Arjun Thakur
Arjun Thakur
Updated on 25-Mar-2026 505 Views

To generate secure random numbers cryptographically we can use the secrets module in Python. This module is helpful to create secure passwords, account authentication tokens, security tokens, and other cryptographic secrets. The secrets module provides access to the most secure source of randomness that your operating system provides, making it suitable for managing secrets where security is essential. Importing the Secrets Module To use the classes and functions of the secrets module, we need to import it into our code ? import secrets Random Number Generation Methods The secrets module provides several ...

Read More

Secure Hashes and Message Digest in Python

Chandu yadav
Chandu yadav
Updated on 25-Mar-2026 2K+ Views

The hashlib module in Python provides a common interface for secure hash algorithms like SHA1, SHA224, SHA256, SHA512, and RSA's MD5. These algorithms are essential for data integrity verification, password storage, and digital signatures. To use hashlib, import it at the beginning of your Python code ? import hashlib Available Hash Algorithms You can check which algorithms are available on your system ? import hashlib print("Guaranteed algorithms:", hashlib.algorithms_guaranteed) print("Available algorithms:", hashlib.algorithms_available) Guaranteed algorithms: {'sha3_224', 'sha256', 'sha3_256', 'md5', 'sha1', 'sha224', 'sha512', 'sha3_384', 'sha384', 'sha3_512'} Available algorithms: {'sha3_224', 'sha256', 'sha3_256', ...

Read More

Python Container Datatypes

Arjun Thakur
Arjun Thakur
Updated on 25-Mar-2026 2K+ Views

Python's collections module provides specialized container datatypes that serve as alternatives to built-in containers like dict, list, and set. These containers offer enhanced functionality and performance for specific use cases. Collections Module Container Types Container Description namedtuple() Creates tuple subclasses with named fields for better readability deque Double-ended queue optimized for adding/removing from both ends Counter Dict subclass for counting hashable objects ChainMap Creates a single view of multiple mappings OrderedDict Dict that remembers insertion order (deprecated in Python 3.7+) UserList Wrapper around list ...

Read More
Showing 6171–6180 of 25,466 articles
« Prev 1 616 617 618 619 620 2547 Next »
Advertisements