Smita Kapse

Smita Kapse

388 Articles Published

Articles by Smita Kapse

388 articles

Python Context Variables

Smita Kapse
Smita Kapse
Updated on 25-Mar-2026 1K+ Views

Context variables can have different values depending on their context. Unlike Thread-Local Storage where each execution thread may have a different value for a variable, a context variable may have several contexts in one execution thread. This is useful for keeping track of variables in concurrent asynchronous tasks. The ContextVar class is used to declare and work with Context Variables. Creating a Context Variable You can create a context variable with an optional default value ? import contextvars name = contextvars.ContextVar("name", default="Hello") print(f"Variable name: {name.name}") print(f"Default value: {name.get()}") Variable name: name ...

Read More

Generate and parse Mac OS X .plist files using Python (plistlib)

Smita Kapse
Smita Kapse
Updated on 25-Mar-2026 2K+ Views

Files with .plist extension are used by macOS applications to store application properties. The plistlib module provides an interface to read and write these property list files in Python. The plist file format serializes basic object types like dictionaries, lists, numbers, and strings. Usually, the top-level object is a dictionary. Values can be strings, integers, floats, booleans, tuples, lists, and dictionaries (but only with string keys). Main Functions Function Description load() Read a plist file from a readable binary file object dump() Write value to a plist file via writable binary ...

Read More

Limited-Contention Protocols

Smita Kapse
Smita Kapse
Updated on 16-Mar-2026 8K+ Views

Limited Contention Protocols are media access control (MAC) protocols that combine the advantages of collision-based protocols and collision-free protocols. They behave like slotted ALOHA under light loads and bitmap protocols under heavy loads, adapting dynamically to network conditions. How It Works In computer networks, when multiple stations try to transmit simultaneously via a shared channel, the transmitted data becomes garbled in an event called collision. Limited contention protocols address this by using an adaptive approach: Under light loads − Behave like slotted ALOHA where all stations can compete freely for transmission slots Under ...

Read More

Execute a script when the browser starts to work online in HTML?

Smita Kapse
Smita Kapse
Updated on 16-Mar-2026 180 Views

The ononline event attribute in HTML executes a JavaScript function when the browser detects that it has regained internet connectivity. This event is fired when the browser transitions from offline to online mode, making it useful for handling network state changes in web applications. Syntax Following is the syntax for the ononline attribute − The ononline attribute is typically used on the element and calls a JavaScript function when the browser goes online. How It Works The browser monitors network connectivity and fires the online event when: The ...

Read More

How to play sound file in a web-page in the background?

Smita Kapse
Smita Kapse
Updated on 16-Mar-2026 26K+ Views

The HTML audio element is the modern standard for adding audio to web pages. To play a sound file in the background automatically when a page loads, you can use the element with the autoplay and loop attributes. The element can also be used but is less recommended for modern web development. Syntax Following is the syntax for the HTML audio element − Your browser does not support the audio element. Following is the syntax for the embed element ...

Read More

How to specify the HTTP method to use when sending form-data in HTML?

Smita Kapse
Smita Kapse
Updated on 16-Mar-2026 322 Views

The method attribute in HTML forms specifies the HTTP method to use when sending form data to the server. This attribute determines how the browser packages and transmits the form data when the user submits the form. Syntax Following is the syntax for the method attribute − The value can be either get or post, with get being the default if not specified. HTTP Methods HTML forms support two primary HTTP methods − GET Method The GET method appends form data to the URL as ...

Read More

How to specify the URL of the image to use in different situations in HTML?

Smita Kapse
Smita Kapse
Updated on 16-Mar-2026 387 Views

Use the srcset attribute to specify the URL of the image to use in different situations in HTML. This attribute allows you to provide multiple image sources for responsive images, enabling browsers to choose the most appropriate image based on screen size, resolution, or other conditions. Syntax The srcset attribute can be used in two main ways − Using srcset with img Element The srcset attribute on the element allows you to specify multiple image sources with their respective widths or pixel densities. The browser automatically selects ...

Read More

How to specify whether the or the element should have autocomplete enabled in HTML?

Smita Kapse
Smita Kapse
Updated on 16-Mar-2026 219 Views

The autocomplete attribute in HTML controls whether the browser should automatically suggest previously entered values for form fields. This feature helps users fill forms more efficiently by displaying a dropdown of suggested values based on their input history. Syntax Following is the syntax for the autocomplete attribute on the element − Following is the syntax for the autocomplete attribute on the element − Autocomplete Values The autocomplete attribute accepts the following values − Value Description ...

Read More

Execute a script when the seeking attribute is set to true indicating that seeking is active in HTML?

Smita Kapse
Smita Kapse
Updated on 16-Mar-2026 170 Views

The onseeking event attribute in HTML is triggered when the user starts seeking (moving to a different position) in an audio or video element. This event fires when the seeking process begins, before the media actually jumps to the new position. Syntax Following is the syntax for the onseeking event attribute − The onseeking attribute accepts a JavaScript function that executes when the seeking operation starts. This is commonly used to provide user feedback or track user interactions with media content. How It Works When a user drags the progress ...

Read More

How to draw circle in HTML page?

Smita Kapse
Smita Kapse
Updated on 16-Mar-2026 10K+ Views

To draw a circle in HTML page, use SVG, HTML5 Canvas, or CSS. The most common approach is using CSS with the border-radius property set to 50% on a square element. SVG provides more control for complex graphics, while Canvas allows dynamic drawing with JavaScript. Using CSS Border-Radius The simplest method to create a circle is using CSS. Set equal width and height on an element, then apply border-radius: 50% to make it perfectly circular. Example − Basic CSS Circle CSS Circle ...

Read More
Showing 1–10 of 388 articles
« Prev 1 2 3 4 5 39 Next »
Advertisements