[Web-SIG] Form field dictionaries

David Fraser davidf at sjsoft.com
Fri Oct 24 12:28:28 EDT 2003


Gregory (Grisha) Trubetskoy wrote:

>On Fri, 24 Oct 2003, Simon Willison wrote:
>
>  
>
>>script.py?a=1&a=2
>>
>>What should GET['a'] return?
>>    
>>
>
>I think this is adequately addressed in the FieldStorage starting with
>Python 2.2 with getfirst() and getlist():
>
>http://www.python.org/doc/current/lib/node404.html
>
>Grisha
>
>  
>
That's fine, but I think it's important that these methods are available 
as an addition to a standard dictionary interface.
I think the key point is, if somebody wants a list of values, they 
probably know that they want a list.
It's very difficult to write code by accident that would handle a list 
of values as well as a string.
So if somebody knows they want a list in certain circumstances, they 
could call getlist()
But I think the default dictionary return value should be the same as 
getfirst().
That saves endless checks for lists for those who don't need them.

David





More information about the Web-SIG mailing list