[Web-SIG] Re: Form field dictionaries

Barry Warsaw barry at python.org
Fri Oct 24 11:44:49 EDT 2003


On Fri, 2003-10-24 at 11:35, Ian Bicking wrote:

> I think this is already really decided -- if (and only if) there are 
> multiple values, then a list should appear in the output.  I.e., {'a': 
> ['1', '2']}.  This is how cgi works, and how almost all Python request 
> objects work.  When there's near-consensus in previous implementations, 
> I think we should keep the conventional behavior.  Plus, it means less 
> things to decide, which should make the design faster to create.

I agree that it's basically decided, but I want to be clear in any
standard that we develop, exactly what the return types are in that
case, and/or how to test for one or the other.  E.g. you can't use len()
because both lists and strings are sequences.  If the way to type test
the value is going to be "isinstance(val, list)", let's set that in
stone.

Here's another alternative, if Python 2.2 is the minimal requirement
(and I think it should be, if not Python 2.3).  Return string and list
subclasses, which will act perfectly string-like and list-like in those
contexts, but which support extended protocols.  See attached example.

>>> show(s)
single value: hello
>>> show(l)
multi value: hello, world

-Barry



-------------- next part --------------
A non-text attachment was scrubbed...
Name: websig.py
Type: text/x-python
Size: 307 bytes
Desc: 
Url : http://mail.python.org/pipermail/web-sig/attachments/20031024/0ba07080/websig.py


More information about the Web-SIG mailing list