Rajendra Dharmkar has Published 452 Articles

How does concatenation operator work on tuple in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 05-Sep-2022 09:17:09

1K+ Views

A tuple is a collection of python objects that are separated by commas which are 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. tup=('tutorials', 'point', 2022, ... Read More

How to pass Drop Down Box Data to Python CGI script?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 25-Jun-2020 21:12:50

452 Views

Passing Drop Down Box Data to CGI ProgramDrop Down Box is used when we have many options available but only one or two will be selected.Here is example HTML code for a form with one drop down box − Maths ... Read More

What is the difference between 'except Exception as e' and 'except Exception, e' in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 25-Jun-2020 20:57:23

914 Views

The difference between using ', ' and 'as' in except statements, is as follows:Both ', ' and 'as' are same functionality wise; but their use depends on the python versions as follows.In Python 2.5 and earlier versions, use of the 'comma' is recommended since 'as' isn't supported.In Python 2.6+ versions, ... Read More

How to configure Apache for Python CGI Programming?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 16-Jun-2020 12:45:17

2K+ Views

Configure Apache Web server for CGITo get your server run CGI scripts properly, you have to configure your Web server. We will discuss how to configure your Apache web server to run CGI scripts.Using ScriptAliasYou may set a directory as ScriptAlias Directive (options for configuring Apache). This way, Apache understands ... Read More

How to retrieve cookies in Python CGI Programming?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 16-Jun-2020 12:32:59

725 Views

Retrieving CookiesIt is very easy to retrieve all the set cookies. Cookies are stored in CGI environment variable HTTP_COOKIE and they will have following form −key1 = value1;key2 = value2;key3 = value3....Here is an example of how to retrieve cookies.#!/usr/bin/python # Import modules for CGI handling from os import environ ... Read More

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

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 16-Jun-2020 12:31:23

2K+ Views

GET and POST MethodsYou must have come across many situations when you need to pass some information from your browser to web server and ultimately to your CGI Program. Most frequently, browser uses two methods two pass this information to web server. These methods are GET Method and POST Method.Passing ... Read More

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

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 16-Jun-2020 12:25:28

267 Views

HTTP HeaderThe line Content-type:text/html\r\r is part of HTTP header which is sent to the browser to understand the content. All the HTTP header will be in the following form −HTTP Field Name − Field ContentFor ExampleContent-type − text/html\r\rThere are few other important HTTP headers, which we will use frequently in ... Read More

What are the modules required for CGI programming in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 16-Jun-2020 12:21:40

151 Views

Python's cgi module is usually the starting place in writing CGI programs in Python. The main purpose of the cgi module is to extract the values passed to a CGI program from an HTML form. Mostly one interacts with CGI applications through an HTML form. One fills out some values ... Read More

How to write Python regular expression to get zero or more occurrences within the pattern?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 16-Jun-2020 12:20:19

383 Views

*      An asterisk meta-character  in a regular expression indicates 0 or more occurrences of the pattern to its leftThe following code matches and prints the zero or more occurrences of the pattern '\w' in the string 'chihua huahua'Exampleimport re s = 'chihua huahua' result = re.findall(r'\w*', s) print ... Read More

How to pass Text Area Data to Python CGI script?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 16-Jun-2020 12:18:43

612 Views

Passing Text Area Data to CGI ProgramTEXTAREA element is used when multiline text has to be passed to the CGI Program.Here is example HTML code for a form with a TEXTAREA box − Type your text here... The result of this code is the following form −Type ... Read More

Advertisements