Articles on Trending Technologies

Technical articles with clear explanations and examples

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 493 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

Python Helpers for Computing Deltas

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 315 Views

The difflib module in Python provides tools for computing deltas between sequences. It's particularly useful for comparing files and generating difference reports in various formats including HTML, context, and unified diffs. import difflib SequenceMatcher Class The difflib.SequenceMatcher class compares two sequences of any type and provides detailed comparison methods ? Key Methods set_seqs(a, b) − Set both sequences to compare. Computes and caches detailed information about the second sequence. set_seq1(a) − Set the first sequence to compare. set_seq2(b) − Set the second sequence to compare. find_longest_match(alo, ahi, blo, bhi) − Find the ...

Read More

Python GNU readline Interface

Chandu yadav
Chandu yadav
Updated on 25-Mar-2026 976 Views

The readline module is a UNIX-specific interface to the GNU readline library. It provides functions to manage command history, line editing, and tab completion in Python's interactive interpreter. This module can enhance the user experience by enabling features like command history persistence and custom completion. For macOS systems, the readline module may use the libedit library instead of GNU readline, which has different configuration options. Importing the Module To use the readline functionality, import the module in your Python code ? import readline Key Functions Function Description readline.parse_and_bind(string) ...

Read More

Python Context Manager Types

Chandu yadav
Chandu yadav
Updated on 25-Mar-2026 261 Views

Python context managers enable automatic resource management using the with statement. They define what happens when entering and exiting a runtime context, ensuring proper cleanup of resources like files, database connections, or locks. Context managers implement two special methods to define their behavior ? The __enter__() Method The __enter__() method is called when entering the runtime context. It sets up the resource and returns an object that will be assigned to the variable after the as keyword in the with statement. class SimpleContext: def __enter__(self): ...

Read More

Python Sequence Types

SaiKrishna Tavva
SaiKrishna Tavva
Updated on 25-Mar-2026 11K+ Views

In Python programming, sequence types are fundamental data structures that hold an ordered collection of items. The main sequence types include Lists, Strings, Tuples, and Range objects. These data structures allow us to access their elements through indexing and iteration. Sequence Types in Python Sequence types in Python are categorized into two main types: mutable and immutable sequences. Mutable Sequence Types These sequences can be changed after their creation. You can modify elements, add new elements, and remove existing ones. Lists: A mutable, ordered collection of items that can store ...

Read More

Python program for removing n-th character from a string?

Akshitha Mote
Akshitha Mote
Updated on 25-Mar-2026 1K+ Views

Removing the nth character from a string is a common string manipulation task in Python. We can accomplish this using several approaches: for loops, string slicing, or the replace() method. Let's explore each method with examples. Understanding the Problem When removing the nth character, remember that Python uses zero-based indexing. So the 1st character is at index 0, the 2nd character is at index 1, and so on. To remove the nth character, we target index n-1. Using a For Loop The for loop approach iterates through each character and skips the one at the target ...

Read More

Python program to check for URL in a string

Sarika Singh
Sarika Singh
Updated on 25-Mar-2026 3K+ Views

This article will teach you how to determine whether a string contains a URL or not. In Python, strings are collections of bytes that represent Unicode characters. When given a string, we will first determine whether it contains a URL and then extract it using regular expressions. Using findall() Method We will use Python's regular expression concept to solve this problem. Regular expressions are supported by the Python re module. The findall() method returns a list of all matches found in the string, scanning from left to right. Syntax re.findall(pattern, string) Example ...

Read More
Showing 7211–7220 of 61,303 articles
« Prev 1 720 721 722 723 724 6131 Next »
Advertisements