Server Side Programming Articles

Page 628 of 2109

How do cookies work in Python CGI Programming?

Rajendra Dharmkar
Rajendra Dharmkar
Updated on 24-Mar-2026 665 Views

HTTP protocol is a stateless protocol, meaning it doesn't remember information between requests. For commercial websites, it's essential to maintain session information across different pages. For example, user registration may span multiple pages, requiring session data persistence. In many situations, using cookies is the most efficient method of remembering and tracking preferences, purchases, commissions, and other information required for better visitor experience or site statistics. How Cookies Work Your server sends data to the visitor's browser in the form of a cookie. The browser may accept the cookie and store it as a plain text record on ...

Read More

What is the difference between GET and POST in Python CGI Programming?

Rajendra Dharmkar
Rajendra Dharmkar
Updated on 24-Mar-2026 2K+ Views

In Python CGI Programming, the two primary methods for passing information from a web browser to a web server are GET and POST. Understanding their differences is crucial for web development security and functionality. GET Method The GET method sends encoded user information appended to the page request. The page and the encoded information are separated by the ? character as follows − http://www.test.com/cgi-bin/hello.py?key1=value1&key2=value2 The GET method is the default method to pass information from browser to web server. It produces a long string that appears in your browser's Location box. Never use GET ...

Read More

What are important HTTP headers to be frequently used in Python CGI Programming?

Rajendra Dharmkar
Rajendra Dharmkar
Updated on 24-Mar-2026 435 Views

HTTP headers are essential components in Python CGI programming that provide metadata about the response being sent to the browser. They define how the browser should interpret and handle the content. HTTP Header Format The line Content-type:text/html\r\r is part of HTTP header which is sent to the browser to understand the content. All HTTP headers follow this format ? HTTP Field Name − Field Content Example Content-type: text/html\r\r Common HTTP Headers in CGI Here are the most frequently used HTTP headers in Python CGI programming ? Sr.No. Header ...

Read More

What Content-type is required to write Python CGI program?

Rajendra Dharmkar
Rajendra Dharmkar
Updated on 24-Mar-2026 426 Views

When writing Python CGI programs, you must specify a Content-type header to tell the browser how to interpret the response. This is essential for proper web communication between your CGI script and the client's browser. Basic Content-type Header The first line of any CGI program output must be a Content-type header followed by a blank line ‒ #!/usr/bin/env python3 print("Content-type: text/html\r\r") print("") print("Hello CGI") print("") print("Hello from Python CGI!") print("") print("") Why the Content-type Header is Required The Content-type header tells the browser: What type of content to expect (HTML, ...

Read More

How can I convert a Python tuple to string?

Gireesha Devara
Gireesha Devara
Updated on 24-Mar-2026 11K+ Views

A tuple is a collection of objects that is ordered and immutable. Tuples are sequences, just like lists. The differences between tuples and lists are that tuples cannot be changed, unlike lists, and tuples use parentheses, whereas lists use square brackets. Converting a Python tuple to a String There are three different ways we can convert a Python tuple to a string: Using a for loop ...

Read More

What is the difference between dict.items() and dict.iteritems() in Python?

Akshitha Mote
Akshitha Mote
Updated on 24-Mar-2026 731 Views

In Python, dict.items() and dict.iteritems() are methods used to access dictionary key-value pairs. The key difference is that dict.items() returns a list of tuple pairs in Python 2 (dict_items view in Python 3), while dict.iteritems() returns an iterator over the dictionary's (key, value) pairs. Note that dict.iteritems() was removed in Python 3. dict.items() in Python 2 In Python 2, dict.items() returns a list of tuples ? # Python 2 syntax (cannot run online) my_dict = {1: 'one', 2: 'two', 3: 'three', 4: 'four'} print(my_dict.items()) print(type(my_dict.items())) [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')] ...

Read More

How can I iterate through two lists in parallel in Python?

Gireesha Devara
Gireesha Devara
Updated on 24-Mar-2026 1K+ Views

In Python, iterating through two or more lists in parallel is a common task. Python provides several methods to achieve this, each with different behaviors for handling lists of unequal lengths. Using range() with Index-Based Access The most basic approach uses range() with the len() function to iterate through both lists using indices ? Example When both lists have the same length ? letters = ['a', 'b', 'c', 'd', 'e'] numbers = [97, 98, 99, 100, 101] length = len(letters) # Assuming both lists have same length for i in range(length): ...

Read More

How do I check what version of Python is running my script?

Gireesha Devara
Gireesha Devara
Updated on 24-Mar-2026 967 Views

Python is being updated regularly with new features and support. Starting from 1994 to the current release, there have been lots of updates in Python versions. Using Python standard libraries like sys or platform modules, we can get the version information of Python that is actually running on our script. In general, the Python version is displayed automatically on the console immediately after starting the interpreter from the command line ? Python 3.10.7 (tags/v3.10.7:6cc6b13, Sep 5 2022, 14:08:36) [MSC v.1933 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. ...

Read More

Do you think garbage collector can track all the Python objects?

Akshitha Mote
Akshitha Mote
Updated on 24-Mar-2026 302 Views

The garbage collector in Python can track most objects, but it focuses specifically on unreachable objects (reference count of zero) and objects involved in circular references. Understanding when and how garbage collection works is crucial for memory management. What is a Garbage Collector? The garbage collector is an automatic process that handles memory allocation and deallocation, ensuring efficient memory usage. Python uses reference counting as its primary memory management mechanism, with garbage collection as a backup for special cases. We can interact with the garbage collector explicitly using the gc module. By default, it is enabled, but ...

Read More

Is there any Python object inspector?

Gireesha Devara
Gireesha Devara
Updated on 24-Mar-2026 591 Views

Python doesn't have a built-in object inspector, but it provides several powerful functions and modules for examining objects. Functions like type(), help(), dir(), vars(), and the inspect module help you discover attributes, properties, and methods of any object. Additional functions like id(), getattr(), hasattr(), globals(), locals(), and callable() are useful for examining object internals. Let's explore these inspection techniques using a simple class example. Sample Class for Demonstration First, let's create a Height class that we'll use throughout our examples ? class Height: """ A height class ...

Read More
Showing 6271–6280 of 21,090 articles
« Prev 1 626 627 628 629 630 2109 Next »
Advertisements