Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Python Articles
Page 725 of 855
Birthday Reminder Application in Python
In this tutorial, we will create a birthday reminder application using Python that checks for birthdays on the current date and sends system notifications. Problem Statement Create a Python application that checks whether there is any birthday on the current day. If it's someone's birthday from our list, send a system notification with their name. We need a lookup file to store dates and names. Create a text file named birth_day_lookup.txt with this format ? 10-January John Doe 15-March Jane Smith 22-December Alice Johnson ...
Read MoreUnix filename pattern matching in Python
Unix filename pattern matching in Python is accomplished using the fnmatch module. This module provides shell-style pattern matching capabilities to compare filenames against patterns and returns True or False based on matches. Importing the fnmatch Module First, import the fnmatch module from Python's standard library ? import fnmatch Unix Wildcard Patterns The fnmatch module supports standard Unix wildcards ? * − Matches any number of characters (including none) ? − Matches exactly one character [seq] − Matches any character in the sequence [!seq] − Matches any character not in the sequence ...
Read MorePython Interface to UNIX syslog library routines
The syslog module provides a Python interface to the UNIX system logging facility. It allows your Python programs to send messages to the system log, which administrators can monitor for debugging and system monitoring purposes. To use this module, we need to import it ? import syslog syslog.syslog() Method This method sends a string message to the system logger. You can specify a priority level for the message. Syntax syslog.syslog(message) syslog.syslog(priority, message) Parameters: message - String message to log priority - Optional priority level (LOG_DEBUG, LOG_INFO, LOG_NOTICE, LOG_WARNING, ...
Read MoreResource Usage Information using Python
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 MorePython Interface to Shell Pipelines
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 MoreThe fcntl and ioctl System Calls in Python
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 MorePOSIX Style TTY control using Python
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 MoreHow we can compress large Python files?
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 MoreThe most Common POSIX System Calls in Python
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 MoreConvenient Web-browser controller in Python
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