tags:

views:

1697

answers:

4

In PHP I simply write:

$bob = $_POST['bob'];

How do I do the same in Python?

And yes, I do normally check that it exists etc, I'm just stripping it down specifically to the functionality I am after.


Edit: I am not using a framework

A: 

Well, that really depends on what framework you are using. Elaborate?

William Keller
I am not using a framework, if I was then I'd have said so :)
Teifion
I agree with William. Your question should have been more clear. There isn't enough context, regardless if you implied any.
fuentesjr
+1  A: 

Full example of how to process forms, including POST values, can be found here http://www.pyzine.com/Issue008/Section_Articles/article_CGIOne.html

Nikki9696
+7  A: 

The simplest method is the 'cgi' module:

import cgi
data = cgi.FieldStorage()
data['bob']

But the context you are executing in (frameworks you're using, WSGI or even (heaven forbid) mod_python) may have different, more efficient or more direct methods of access.

Thomas Wouters
A: 

What exactly are you coding for? Is it a CGI scritpt in python? a wsgi application? a django/pylons/whateverframework application?

Vasil