Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8966621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:03:45+00:00 2026-06-15T17:03:45+00:00

I was playing around with python and cgi and was wondering why there is

  • 0

I was playing around with python and cgi and was wondering why there is a difference between the two examples below:

Example 1 (partial)

form = cgi.FieldStorage()
for field in form.keys():
    sys.stdout("%s ----> %s<br />" % (field, form[field].value))

Example 2

form = {'one': '1', 'two': '2', 'three': '3'}
for field in form.keys():
    sys.stdout("%s ---> %s\n" % (field, form[field]))

Why do you need the .value attribute in the first example, but in the second example you do not require it to return the key’s value?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:03:45+00:00Added an answer on June 15, 2026 at 5:03 pm

    in the first example.

    form = cgi.FieldStorage()
    

    form is now an object of the type FieldStorage this object can be accessed like a dictionary (object[key]) and it will return an object, however, unlike a normal dictionary like in example 2 which contains just strings. the object returned in example 1’s dictionary-like access must be told how you want to display it, or access it, in this case, you want the objects value.

    to better understand this, you could try some on-the-fly debugging.

    by iterating over the items in cgi.FieldStorage() and then you can see what kind of objects they are. maybe try playing with an individual object and see how it works?

    incidently, if the object has a __str__ function you might not need the .value for more information you can read about classes and __str__

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was playing around with Python's subprocess module, trying a few examples but I
There is an eval() function in Python I stumbled upon while playing around. I
I'm playing around with property in Python and I was wondering how this @propertyName.deleter
I'm playing around with the XCF active memory server. Is there a python library
Playing around with Python - tkInter - Entry widget - when I use validatecommand
I have been playing around with Python and math lately, and I ran in
I've been playing around with Python's imaplib and email module recently. I tried sending
I was just playing around with the python command line and the ** operator,
I'm playing around a little with Python and curses. When I run import time
I was playing around with clever ways to create a python generator for sequence

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.