Prev: TypeError
Next: QDoubleValidator
From: Steve Holden on 8 Jan 2010 09:40 Victor Subervi wrote: [...] > TypeError: unsubscriptable object > args = ('unsubscriptable object',) > > Why is the value undefined? What is an unsubscriptable object? > TIA, > beno > Sorry, that wasn't very helpful. Here's some more advice: Google is you friend. Try Googling for components of the error traceback. It's unlikely you are the first person to experience this problem. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/ Holden Web LLC http://www.holdenweb.com/ UPCOMING EVENTS: http://holdenweb.eventbrite.com/
From: Carsten Haese on 8 Jan 2010 09:55 Victor Subervi wrote: > First I get scolded for not including enough information. Now I get > scolded for including too much. Seems I can't win. I *am* putting effort > into understanding this. I'm sorry I'm not as sharp as you are in these > matters. I didn't scold you for including too much information. I scolded you for not demonstrating any effort on your part to try to figure out the problem. Maybe you did put effort into figuring it out, but you didn't show us any of it. You simply threw your entire code out there and asked an open-ended question that gave us no insight into your thought process. > params = {}, key = 'store', global cgi = <module 'cgi' from > '/usr/lib64/python2.4/cgi.pyc' >>, cgi.FieldStorage = <class cgi.FieldStorage>, ].value undefined > > TypeError: unsubscriptable object > args = ('unsubscriptable object',) > > Why is the value undefined? What is an unsubscriptable object? At least those are specific questions. "value undefined" means that the cgitb traceback is unable to show a meaningful value for the object known as <<cgi.FieldStorage>>. Maybe you should ask yourself why that is and why you're operating on an object that doesn't have a meaningful value. An unsubscriptable object is an object that can't be subscripted. In other words, it's an object <<foo>> for which the expression foo[bar] is invalid and results in exactly the kind of exception you're struggling with right now. -Carsten
From: MRAB on 8 Jan 2010 10:39 Victor Subervi wrote: [snip] > > Code snippet: > > def cgiFieldStorageToDict(fieldStorage): > params = {} > for key in fieldStorage.keys(): > params[key] = cgi.FieldStorage[key].value ^^^^^^^^^^^^^^^^^^^^^ This is your problem. > return params > [snip]
From: Steve Holden on 8 Jan 2010 12:26 MRAB wrote: > Victor Subervi wrote: > [snip] >> >> Code snippet: >> >> def cgiFieldStorageToDict(fieldStorage): ^^^^^^^^^^^^ Further hint ... >> params = {} >> for key in fieldStorage.keys(): >> params[key] = cgi.FieldStorage[key].value > ^^^^^^^^^^^^^^^^^^^^^ > This is your problem. > >> return params >> > [snip] > regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/ Holden Web LLC http://www.holdenweb.com/ UPCOMING EVENTS: http://holdenweb.eventbrite.com/
From: Jean-Michel Pichavant on 8 Jan 2010 13:52
Victor Subervi wrote: > On Fri, Jan 8, 2010 at 1:26 PM, Steve Holden <steve(a)holdenweb.com > <mailto:steve(a)holdenweb.com>> wrote: > > MRAB wrote: > > Victor Subervi wrote: > > [snip] > >> > >> Code snippet: > >> > >> def cgiFieldStorageToDict(fieldStorage): > ^^^^^^^^^^^^ > Further hint ... > > >> params = {} > >> for key in fieldStorage.keys(): > >> params[key] = cgi.FieldStorage[key].value > > ^^^^^^^^^^^^^^^^^^^^^ > > This is your problem. > > > The problem is that I don't understand this code that I exactly copied > from a Web page tutorial. Can you folks point me to tutorials where I > can learn to comprehend this code? Specifically, the line in question. > How is it that one can code "params[key]" (what does that mean?) and > the other side, what does that mean I think you are gathering more fans Victor :) http://docs.python.org/tutorial/datastructures.html#dictionaries JM |