Rajendra Dharmkar has Published 139 Articles

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

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:21

392 Views

If we run simple scripts like hello.py, its output is written on the STDOUT file, i.e., screen. There is one important and extra feature available which is the first line to be printed Content-type:text/html\r\r. This line is sent back to the browser and it specifies the content type to be displayed ... Read More

How do cookies work in Python CGI Programming?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:21

635 Views

Using Cookies in CGIHTTP protocol is a stateless protocol. For a commercial website, it is required to maintain session information among different pages. For example, one user registration ends after completing many pages. How to maintain user's session information across all the web pages?In many situations, using cookies is the ... Read More

What is the difference between time.clock() and time.time()?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:21

676 Views

The function time.time() returns the time in seconds since the epoch, i.e., the point where the time starts.For Unix, the epoch is January 1, 1970. For Windows, the epoch is January 1, 1601.time.time() is used for benchmarking on Windows. time.time() behaves the same on both UNIX and Windows but time.clock() ... Read More

How to use Python modules over Paramiko (SSH)?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:20

652 Views

You connect and use a python module on the remote computer over SSH, as SSH only provides limited functionality so calling the module isn't possible.You can call a script on the remote server and run that as a way of getting around this problem. To get a result from the ... Read More

Is it possible to use Python modules in Octave?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:20

361 Views

There is no straightforward way to do this. But it is possible to run a Python program and parse the output. You can execute any shell command using the function system (cmd, flag). The second argument is optional. If it is present, the output of the command is returned by ... Read More

How to prohibit a Python module from calling other modules?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:20

288 Views

You can use "Sandboxed Python". A "Sandboxed Python" would let you permit or forbid modules, limit execution slices, permit or deny network traffic, constrain filesystem access to a particular directory (floated as "/"), and so on. It is also referred to as RestrictedExecution. There are many ways to implement sandboxing ... Read More

Do recursive functions in Python create a new namespace each time the function calls itself?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:20

230 Views

Yes, a function call (any function call, not just recursive ones) creates a new namespace. BUT, when given as parameters, OBJECTS are passed by reference.So, the new namespace get its own copy of this reference but it still refers to the same object as in the calling function, and if ... Read More

What is the max length of a Python string?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:20

4K+ Views

With a 64-bit Python installation, and 64 GB of memory, a Python 2 string of around 63 GB should be quite feasible. If you can upgrade your memory much beyond that, your maximum feasible strings should get proportionally longer. But this comes with a hit to the runtimes.With a typical ... Read More

Where can I find good reference document on python exceptions?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:20

124 Views

The following link is a  good reference document on python exceptionshttps://docs.python.org/2/library/exceptions.html

Advertisements