Articles on Trending Technologies

Technical articles with clear explanations and examples

XMLRPC server and client modules in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 4K+ Views

XML-RPC (XML Remote Procedure Call) is a protocol that allows programs to make function calls over HTTP using XML for encoding. Python's xmlrpc.server and xmlrpc.client modules make it easy to create cross-platform, language-independent servers and clients. Creating an XML-RPC Server We use SimpleXMLRPCServer to create a server instance and register functions that clients can call remotely. The server listens for incoming requests and executes the appropriate functions ? Example from xmlrpc.server import SimpleXMLRPCServer from xmlrpc.server import SimpleXMLRPCRequestHandler class RequestHandler(SimpleXMLRPCRequestHandler): rpc_paths = ('/RPC2', ) with SimpleXMLRPCServer(('localhost', 9000), ...

Read More

Python Code Objects

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 2K+ Views

Code objects are a low-level detail of the CPython implementation. Each one represents a chunk of executable code that hasn't yet been bound into a function. Though code objects represent some piece of executable code, they are not, by themselves, directly callable. To execute a code object, you must use the exec() function. Code objects are created using the compile() function and contain various attributes that provide information about the compiled code, such as bytecode, variable names, and filename. Creating a Code Object Use the compile() function to create a code object from a string of Python ...

Read More

Python a += b is not always a = a + b

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 199 Views

In Python, the expressions a += b and a = a + b are not always equivalent, especially when dealing with mutable objects like lists. The key difference lies in how Python handles these operations internally. Understanding the Difference For immutable types like integers and strings, both expressions produce the same result. However, for mutable types like lists, the behavior differs significantly: a = a + b creates a new object a += b modifies the existing object in-place (when possible) Case of a = a + b When using a = a ...

Read More

Python - Create Test DataSets using Sklearn

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 430 Views

The Sklearn Python library provides sample datasets which can be used to create various graph plots. The usefulness of these datasets is in creating sample graphs and charts, predicting graph behavior as values change, and experimenting with parameters like colors and axes before using actual datasets. Using make_blobs The make_blobs function generates isotropic Gaussian blobs for clustering. This is useful for testing clustering algorithms and creating scatter plots with distinct groups of data points. Example In the below example we use the sklearn library along with matplotlib to create a scatter plot with a specific style. ...

Read More

Find maximum length sub-list in a nested list in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 1K+ Views

Finding the maximum length sub-list in a nested list is a common task when working with data structures in Python. This article explores different approaches to identify the longest sub-list and return both the sub-list and its length. Using lambda and max() The most efficient approach combines lambda with the max() function. The max() function uses a key parameter to determine which sub-list has the maximum length ? Example def longest(nested_list): longest_list = max(nested_list, key=lambda i: len(i)) max_length = max(map(len, nested_list)) return longest_list, ...

Read More

Python Generate QR Code using pyqrcode module?

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 562 Views

A QR code consists of black squares arranged in a square grid on a white background, which can be read by an imaging device such as a camera. It is widely used for commercial tracking applications, payment systems, and website login authentication. The pyqrcode module is used to generate QR codes in Python. There are four standardized encoding modes: numeric, alphanumeric, byte/binary, and kanji to store data efficiently. Installation First, install the pyqrcode module using pip ? pip install pyqrcode Basic QR Code Generation We use the pyqrcode.create() function to generate a QR ...

Read More

Python Front and rear range deletion in a list?

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 235 Views

Sometimes we need to remove elements from both the beginning and end of a list simultaneously. Python provides several approaches to delete elements from both the front and rear of a list efficiently. Using List Slicing This approach creates a new list by slicing elements from both ends. The original list remains unchanged ? days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] # Given list print("Given list:", days) # Number of elements to delete from front and rear v = 2 # Create new list excluding v elements from each end new_list ...

Read More

Python file parameter in print()?

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 1K+ Views

The print() function in Python can write text to different destinations using the file parameter. By default, print() outputs to the console, but you can redirect it to files or other output streams. Syntax print(*values, file=file_object, sep=' ', end='', flush=False) The file parameter accepts any object with a write() method, such as file objects, sys.stdout, or sys.stderr. Printing to a File You can write directly to a file by opening it in write mode and passing the file object to the file parameter ? # Open file in write mode with ...

Read More

Python Extract specific keys from dictionary?

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 2K+ Views

Dictionaries are one of the most extensively used data structures in Python. They contain data in the form of key-value pairs. Sometimes you need to extract only specific keys from a dictionary to create a new dictionary. Python provides several approaches to accomplish this task efficiently. Using Dictionary Comprehension with Set Intersection This approach uses dictionary comprehension with set intersection to filter keys. The & operator finds common keys between the dictionary keys and your desired keys ? Example schedule = {'Sun': '2 PM', 'Tue': '5 PM', 'Wed': '3 PM', 'Fri': '9 PM'} # ...

Read More

Python Count set bits in a range?

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 363 Views

A given positive number when converted to binary has a number of set bits. Set bits in a binary number are represented by 1. In this article we will see how to count the number of set bits in a specific range of positions within a binary representation of a number. Using bin() and String Slicing In the below example we take a number and apply the bin() function to get the binary value. Then we slice it to remove the prefixes and count set bits in the specified range ? Example def SetBits_cnt(n, l, ...

Read More
Showing 1–10 of 61,301 articles
« Prev 1 2 3 4 5 6131 Next »
Advertisements