5

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

4
  • Well, that really depends on what framework you are using. Elaborate? Commented Sep 22, 2008 at 19:59
  • I am not using a framework, if I was then I'd have said so :) Commented Sep 22, 2008 at 20:00
  • may be you want to add "http" to the tags, I'm not sure that the tags "post" and "get" applies to this question. Commented Sep 22, 2008 at 20:01
  • 1
    I agree with William. Your question should have been more clear. There isn't enough context, regardless if you implied any. Commented Sep 22, 2008 at 20:09

1 Answer 1

10

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.