Samual Sam

Samual Sam

1,507 Articles Published

Articles by Samual Sam

1,507 articles

Barrier Objects in Python

Samual Sam
Samual Sam
Updated on 25-Mar-2026 605 Views

A Barrier in Python is a synchronization primitive that allows multiple threads to wait at a common point until all required threads reach that point, then releases them all simultaneously. This is useful for coordinating parallel tasks that need to synchronize at specific checkpoints. Syntax To create a barrier object, use the threading.Barrier class ? threading.Barrier(parties, action=None, timeout=None) Parameters parties − Number of threads that must reach the barrier before they are all released action − Optional callable executed by one thread when all threads reach the barrier timeout − Default timeout ...

Read More

Keyed-Hashing for Message Authentication in python

Samual Sam
Samual Sam
Updated on 25-Mar-2026 1K+ Views

Keyed-Hashing for Message Authentication (HMAC) provides secure message authentication using cryptographic hash functions combined with a secret key. Python's hmac module implements this mechanism to ensure data integrity and authenticity during transmission or storage. The basic concept involves generating a cryptographic hash from the actual data combined with a shared secret key. The recipient can verify the message authenticity by recalculating the hash using the same secret key. Syntax hmac.new(key, msg=None, digestmod=None) Parameters: key − The shared secret key (bytes object) msg − The message to hash (optional, can be added later) ...

Read More

Design a Keylogger in Python

Samual Sam
Samual Sam
Updated on 25-Mar-2026 4K+ Views

A keylogger is a program that monitors and records keystrokes. These keystrokes are stored in a log file, potentially capturing sensitive information like usernames and passwords. Here we'll develop a simple keylogger using Python's pynput module. Disclaimer: This tutorial is for educational purposes only. Use keyloggers responsibly and only on systems you own or have explicit permission to monitor. Installing Required Module The pynput module is not part of Python's standard library, so we need to install it ? pip install pynput To verify the installation, import the module in your Python shell ...

Read More

MD5 hash encoding using Python?

Samual Sam
Samual Sam
Updated on 25-Mar-2026 5K+ Views

Data security is a major concern for all IT companies. Multiple hashing techniques are available to protect and verify our data integrity. One of the most commonly used hashing algorithms is MD5, which we can easily implement in Python. What is Hash? A hash function takes a variable-length sequence of bytes as input and converts it to a fixed-length sequence. Getting your original data back from the hash is computationally difficult. For example, if x is your input and f is the hashing function, then calculating f(x) is quick and easy, but trying to obtain x again is ...

Read More

How to generate byte code file in python

Samual Sam
Samual Sam
Updated on 25-Mar-2026 2K+ Views

Python automatically compiles your source code to bytecode (stored in .pyc files) before executing it. This compiled bytecode is stored for faster execution on subsequent runs. When you import a module for the first time, or when your source file is newer than the existing compiled file, Python creates a .pyc file. In Python 3, these files are stored in a __pycache__ subdirectory rather than alongside your .py file. Automatic Bytecode Generation The simplest way to generate a .pyc file is to import the module ? # Create a simple module first (save as test_module.py) ...

Read More

Defining Clean Up Actions in Python

Samual Sam
Samual Sam
Updated on 25-Mar-2026 1K+ Views

There are numerous situations where we want our program to perform specific cleanup tasks, regardless of whether it runs successfully or encounters an error. While we commonly use try and except blocks to handle exceptions, Python provides a special clause for defining cleanup actions. The finally clause in a try statement is designed for defining cleanup actions that must be executed under any circumstances ? Basic Syntax try: raise SyntaxError("Sample error") finally: print("Learning Python!") Learning Python! Traceback (most recent call last): File "", ...

Read More

Writing files in background in Python

Samual Sam
Samual Sam
Updated on 25-Mar-2026 306 Views

Writing files in the background while performing other tasks simultaneously is achieved through multithreading in Python. This allows your program to continue executing other operations without waiting for file I/O operations to complete. Understanding Background File Writing When writing files in the background, we create a separate thread that handles the file operations independently from the main program flow. This is particularly useful for applications that need to log data or save information without blocking user interactions. Implementation Using Threading Here's how to implement background file writing using Python's threading module − import threading ...

Read More

Geographical plotting using Python plotly

Samual Sam
Samual Sam
Updated on 25-Mar-2026 488 Views

Plotly is a powerful Python library for creating interactive geographical visualizations. It provides tools to create choropleth maps, scatter plots on maps, and other geographical charts that help visualize data across different regions. Installing Required Libraries First, install the necessary libraries for geographical plotting ? pip install plotly pandas Creating a Basic Choropleth Map A choropleth map uses different colors to represent data values across geographical regions. Here's how to create one for US states ? import plotly.graph_objects as go import plotly.express as px # Sample data for US states ...

Read More

Simple registration form using Python Tkinter

Samual Sam
Samual Sam
Updated on 25-Mar-2026 23K+ Views

Tkinter is a Python library for developing GUI (Graphical User Interfaces). It comes as a standard package with Python 3.x, so no additional installation is required. This tutorial shows how to create a registration form using Tkinter widgets. Creating a Simple GUI Application Let's start by creating a basic window with a button − from tkinter import * from tkinter import ttk window = Tk() window.title("Welcome to TutorialsPoint") window.geometry('325x250') window.configure(background="gray") ttk.Button(window, text="Hello, Tkinter").grid() window.mainloop() This code creates a simple window with the following components − Tk() − Creates the main window ...

Read More

Basics of Discrete Event Simulation using SimPy in Python

Samual Sam
Samual Sam
Updated on 25-Mar-2026 858 Views

SimPy (rhymes with "Blimpie") is a Python package for process-oriented discrete-event simulation. It allows you to model real-world systems like queues, networks, and resource allocation scenarios. Installation The easiest way to install SimPy is via pip ? pip install simpy To upgrade an existing installation ? pip install -U simpy Note: You need Python 2.7 or above. For Linux/Unix/MacOS, you may need root privileges to install SimPy. To verify the installation, open a Python shell and import simpy ? import simpy print("SimPy installed successfully!") ...

Read More
Showing 1–10 of 1,507 articles
« Prev 1 2 3 4 5 151 Next »
Advertisements